hey everyone,
can anyone tell me why this code isn't working on my 16x1 LCD. channelCounter is a variable that can be anything from 0 to 9999, but I want to insert leading zeros when either the 1000's, 100's or 10's are zero, i.e. if channelCounter = 23, the display should read "Ch. Number:0023"
if (channelCounter < 1000)
{
lcd.clear();
lcd.print("Ch. Numb");
lcd.setCursor(0,1);
lcd.print("er:0");
lcd.setCursor(4,1);
lcd.print(channelCounter);
}
else if (channelCounter < 100)
{
lcd.clear();
lcd.print("Ch. Numb");
lcd.setCursor(0,1);
lcd.print("er:00");
lcd.setCursor(5,1);
lcd.print(channelCounter);
}
else if (channelCounter < 10)
{
lcd.clear();
lcd.print("Ch. Numb");
lcd.setCursor(0,1);
lcd.print("er:000");
lcd.setCursor(6,1);
lcd.print(channelCounter);
}
else if (channelCounter < 1)
{
lcd.clear();
lcd.print("Ch. Numb");
lcd.setCursor(0,1);
lcd.print("er:0000");
}
else
{
lcd.clear();
lcd.print("Ch. Numb");
lcd.setCursor(0,1);
lcd.print("er:");
lcd.setCursor(3,1);
lcd.print(channelCounter);
}