I just started to learn how to code and I use an lcd shield on my Arduino.
What I've tried to do is making a timer where each second appear on the LCD...
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup() {
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("LED CountDown :");
}
void loop() {
lcd.setCursor(0, 2);
lcd.print(millis()/1000);
}
...while making an LED blink ON for 4sec and OFF for 7sec in a loop.
void setup() {
pinMode(2, OUTPUT);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("LED CountDown :");
}
void loop() {
digitalWrite(2, HIGH);
delay(4000);
digitalWrite(2, LOW);
delay(7000);
}
I tried to isolate the delay fonction with While loop but it's still affecting the LCD by applying to it the delay assigned for the blink of the LED.
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup() {
pinMode(2, OUTPUT);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("LED CountDown :");
}
void loop() {
lcd.setCursor(0, 2);
lcd.print(millis()/1000);
int var = 0;
while(var < 1){
digitalWrite(2, HIGH);
delay(4000);
digitalWrite(2, LOW);
delay(7000);
var++;
}
}
I search a lot but I didn't find anything to isolate a loop.