Sketch uses 4048 bytes (12%) of program storage space. Maximum is 32256 bytes.
Global variables use 276 bytes (13%) of dynamic memory, leaving 1772 bytes for local variables. Maximum is 2048 bytes.
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xab
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xab
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xab
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xab
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xab
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xab
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xab
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xab
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xab
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xab
Failed uploading: uploading error: exit status 1
Code compied OK, but there is a problem with communication between the board and PC.
Is the right board selected in the IDE Tools, Boards menu.
Is the correct serial port selected in Tools, Ports.
Is your USB cable a good data cable.
Do a Google search for "troubleshooting arduino upload problems".
the upload is ok now, but now my lcd is displaying gibberish. Here is my schematic
and here is my code
#include <LiquidCrystal.h>
const int rs = 1, en = 2, DB4 = 4, DB5 = 5, DB6 = 6, DB7 =7;
LiquidCrystal lcd(rs,en,DB4,DB5,DB6,DB7);
byte happyface[] = {
B00000,
B00000,
B00000,
B01010,
B00000,
B10001,
B01110,
B00000,
};
byte sadface[] = {
B00000,
B00000,
B00000,
B01010,
B00000,
B01110,
B10001,
B00000,
};
byte ordinary[] = {
B00000,
B00000,
B01010,
B00000,
B11111,
B00000,
B00000,
B00000,
};
byte die[] = {
B00000,
B10101,
B01010,
B10101,
B00000,
B01110,
B01010,
B01110,
};
long duration, distance;
const int trig = 9;
const int echo = 10;
void setup()
{
lcd.begin(16,2);
lcd.createChar(1, happyface);
lcd.createChar(3, sadface);
lcd.createChar(2, ordinary);
lcd.createChar(4, die);
lcd.clear();
lcd.print("Custom Character");
Serial.begin(9600);
pinMode(trig, OUTPUT);
pinMode(echo, INPUT);
}
void loop()
{
digitalWrite(trig,LOW);
delayMicroseconds(2);
digitalWrite(trig,LOW);
delayMicroseconds(10);
digitalWrite(trig,HIGH);
duration = pulseIn (echo, HIGH);
distance = duration/ 57.8;
Serial.println(distance);
if(distance<=25){
lcd.setCursor(0,1);
lcd.write(byte(1));
}
else if(distance>=26&&distance<=100){
lcd.setCursor(0,1);
lcd.write(byte(2));
}
else if(distance>=101&&distance<=150){
lcd.setCursor(0,1);
lcd.write(byte(3));
}
else if(distance>=151&&distance<=250){
lcd.setCursor(0,1);
lcd.write(byte(4));
}
}
Pin 1 is serial TX pin. Use a different pin for LCD RS.
Why is RS connected to the pot?
The pot should only connect to Vcc, Vo and ground.
RW should connect to ground, not Vcc.
so, apart from all the errors you mentioned, there shouldn't be anything wrong with the code?
This should (hopefully) include all changes that @groundFungus mentioned:
Your code works (there is just a gap when the distance measured exceeds the range of 250.
Here is a version of your software that uses switch/case instead of the if/else phrases and only changes the display if a new character has to be written:
/*
Forum: https://forum.arduino.cc/t/im-having-uploading-my-code-to-my-board-this-error-message-show-up/1184392
Wokwi: https://wokwi.com/projects/380195072459624449
*/
#include <LiquidCrystal.h>
const int rs = 8, en = 2, DB4 = 4, DB5 = 5, DB6 = 6, DB7 = 7;
LiquidCrystal lcd(rs, en, DB4, DB5, DB6, DB7);
byte happyface[] = {
B00000,
B00000,
B00000,
B01010,
B00000,
B10001,
B01110,
B00000,
};
byte sadface[] = {
B00000,
B00000,
B00000,
B01010,
B00000,
B01110,
B10001,
B00000,
};
byte ordinary[] = {
B00000,
B00000,
B01010,
B00000,
B11111,
B00000,
B00000,
B00000,
};
byte die[] = {
B00000,
B10101,
B01010,
B10101,
B00000,
B01110,
B01010,
B01110,
};
constexpr byte trig = 9;
constexpr byte echo = 10;
long duration, distance;
char customChar = 0;
char previousCustomChar = 127;
void setup()
{
lcd.begin(16, 2);
lcd.createChar(1, happyface);
lcd.createChar(3, sadface);
lcd.createChar(2, ordinary);
lcd.createChar(4, die);
lcd.clear();
lcd.print("Custom Character");
Serial.begin(9600);
pinMode(trig, OUTPUT);
pinMode(echo, INPUT);
}
void loop()
{
digitalWrite(trig, LOW);
delayMicroseconds(10);
digitalWrite(trig, HIGH);
duration = pulseIn (echo, HIGH);
distance = duration / 57.8;
Serial.println(distance);
switch (distance) {
case 0 ... 25:
customChar = 1;
break;
case 26 ... 100:
customChar = 2;
break;
case 101 ... 150:
customChar = 3;
break;
case 151 ... 250:
customChar = 4;
break;
default:
customChar = '?'; // Display "?"" if distance > 250
break;
}
if (customChar != previousCustomChar) {
lcd.setCursor(0, 1);
lcd.write(customChar);
previousCustomChar = customChar;
}
}
Feel free to check it out on Wokwi:
https://wokwi.com/projects/380195072459624449
I personally find switch/case statements easier to follow than a series of if/else ...
Good luck and have fun!
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.

