ejemplo datos y LCD EDAD — ESP32 simulation

An interactive ESP32 circuit simulation you can run free in your browser on Velxio, by jesantosm.

Components

Sketch code

#include <LiquidCrystal_I2C.h> //libreria para la LCD

LiquidCrystal_I2C LCD = LiquidCrystal_I2C(0x27, 16, 2);


int a,e;
char anio[] = {'A',241,'o','\0'};

void setup() {
  Serial.begin(115200);
  
  LCD.init();
  LCD.backlight();
  LCD.setCursor(0, 0);
  LCD.print("Hola ");
  delay(1000);
  LCD.setCursor(0, 1);
  LCD.print("INGENIEROS ");
  delay(1000);
  LCD.clear();
  LCD.setCursor(0, 0);
  LCD.print("LCD");
  LCD.setCursor(0, 1);
  LCD.print("Listo!");
   Serial.println("ESP32-dev kit v1 Serial Listo!");

   delay(1000);
  
}

void loop() {
  LCD.clear();
  LCD.setCursor(0, 0);
  LCD.print("Escribe tu a");
  LCD.write(char(238));
  LCD.print("o");
  LCD.setCursor(0, 1);
  LCD.print("de nacimiento");
  Serial.print("Escribe tu ");
   Serial.print(anio);
  Serial.println(" de nacimiento y da enter"); 
  delay(500);
  LCD.clear();
    LCD.setCursor(0, 0);
    LCD.print("de nacimiento");
    LCD.setCursor(0, 1);
  LCD.print("y da enter");
  delay(500);

  if (Serial.available()) {
    String input = Serial.readUntil('\n');
    input.trim();
    if (input.length() > 0) {
      a=input.toInt();
      e=2026-a;
      LCD.clear();
      Serial.print("Tienes ");
      Serial.print(e);
      Serial.print(" ");
      Serial.print(anio);
      Serial.println("s aproximadamante.");
      LCD.setCursor(0, 0);
      LCD.print("Tienes ");
      LCD.print(e);
      LCD.setCursor(0, 1);
      LCD.print("A");
      LCD.write(char(238));
      LCD.print("os aprox.");
    }
  }String
  delay(2000);
}

More projects by jesantosm