// HD44780 I2C Example
#include <Wire.h>
#include <hd44780.h> // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header
hd44780_I2Cexp lcd;
//------------------------------------------------------------------
const int LCD_COLS = 20;
const int LCD_ROWS = 4;
int contador = 0;
#define final_contagem 200
//------------------------------------------------------------------
void setup()
{
Serial.begin(115200);
int result = lcd.begin(LCD_COLS, LCD_ROWS);
if (result) {
Serial.print("LCD initialization failed: ");
Serial.println(result);
hd44780::fatalError(result);
}
lcd.print("Hello, Wokwi!");
delay(2000);
demo_R00();
}
//====================================================
void loop()
{
contador_evento_R00();
}
//---------------------------------------------------
//========================================================================
void demo_R00()
{
lcd.clear(); // clear the screen
lcd.setCursor(0, 0); // set the cursor to position 1, line 1
lcd.print("Hello YouTube!"); // write on the screen
//delay(1000);
lcd.setCursor(0, 1);
lcd.print("PROGRAMA TESTE");
lcd.setCursor(0, 2);
lcd.print("ARDUINO UNO");
lcd.setCursor(0, 3);
lcd.print("LCD_I2C_4x20");
delay(2000);
lcd.clear();
delay(500);
}
//========================================================================
void contador_evento_R00()
{
//lcd.clear(); // clear the screen
if (contador > final_contagem)
{
delay(1000);
contador = 0;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("FINAL DE CONTAGEM");
lcd.setCursor(0, 1);
lcd.print("VOLTANDO AO INICIO");
delay(1000);
lcd.clear();
delay(200);
}
//----------------------------
lcd.setCursor(0, 0);
lcd.print("PROGRAMA TESTE");
lcd.setCursor(0, 3);
lcd.print("CONTADOR= ");
lcd.setCursor(10, 3);
lcd.print(contador);
contador++;
delay(200);
}
//========================================================================