Greetings forum,
i'd like to present you with a problem i'm having:
i'm working on a timer of sorts, and since i'm god-awful at code, i'm re-working the "hello world" example (which works fine with my wires).
here's what i have right now:
void setup() {
lcd.begin(16, 2);
lcd.print("Time:");
}
void loop() {
lcd.setCursor (0 ,1);
int time1;
for(time1=0; time1<10; time1++)
{ lcd.print(time1);
delay(1000);
lcd.clear();
}
so the idea is that there's a time1 variable which goes from 0 to 10, with increments each second. it's supposed to look like this on the LCD:
Time:
0-10
here's the problem: at first the LCD says "Time" on the first line, and a "0" on the second line. as soon as the 1 sec delay is up, the screen clears from the lcd.clear function and then the counter moves up on the first row where the "time" was supposed to be.
from there on the counter still works and goes up to 10. then the first line is cleared and "0" is printed on the second line where it was supposed to be, then that is cleared too and the counting resumes on the first line, starting from 1.
here's some more code that didn't work, portrayed in words:
there are supposed to be 3 2-digit numbers printed on the second line of the ldc, and they are supposed to be logically linked with each other like this:
" int a
int b
int c
a++
if a =10, b++
if b =10, c++
if c = 10, a=b=c=0
so it's like a clock that only counts 10 seconds, 10 minutes and 10 hours. After that maybe do a short beep on a buzzer to indicate the start of a new cycle.
i tried setting the cursor to a different place for each number to be printed but that went horribly, with numbers getting printed everywhere on the screen with seemingly no order of appearance.
this last bit of logical binding between the numbers also proves to be an issue, since it looks like the software doesn't like if-s in the void.loop() - and returns a message along the lines of "variable is not defined in this scope". it's OK with for-s though. i guess i should also ask, out of general curiosity, where should i do such logical operations -in the setup, where i define variables, or in the loop- where the lcd.print is done?
that's the just of it, and i'm sorry if i made you facepalm so hard your head hurts. but it is what it is, and if i don't ask how it's supposed to be done i'm not going to get anything done on this project.
anyway, any feedback and/or suggestions will be appreciated!
and remember to have a great day!