#define RED 18
#define YELLOW 16
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
Serial.println("Blinking LED example");
pinMode(RED, OUTPUT);
pinMode(YELLOW, OUTPUT);
// LiquidCrystal setup
lcd.init(); // initialize the lcd
// Print a message to the LCD.
lcd.backlight();
lcd.setCursor(3,0);
lcd.print("Hello, world!");
lcd.setCursor(2,1);
lcd.print("Ywrobot Arduino!");
lcd.setCursor(0,2);
lcd.print("Arduino LCM IIC 2004");
lcd.setCursor(2,3);
lcd.print("Power By Ec-yuan!");
}
byte brojac = 0;
void loop() {
ledLoop();
// radi nešto drugo...
brojac++;
//if (brojac == 0) {
lcd.setCursor(0,0);
lcd.print(" ");
//}
lcd.setCursor(0,0);
lcd.print(brojac);
}
void ledLoop() {
static bool stanje = false;
static unsigned long mils = millis();
if (millis() - mils < 1000)
return;
mils = millis();
stanje = !stanje;
if (stanje) {
digitalWrite(RED, HIGH);
digitalWrite(YELLOW, LOW);
} else {
digitalWrite(RED, LOW);
digitalWrite(YELLOW, HIGH);
}
}