PA 13 00 Display LCD Alternativa I2C
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// Inicializar la pantalla LCD
lcd.begin(16, 2);
// Mostrar un mensaje inicial
lcd.print("Prueba");
}
void loop() {
delay(3000);
lcd.setCursor(0, 0);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Hola Mundo");
lcd.setCursor(0, 1);
lcd.print("Hello!");
}
PA 13 01 Display LCD Scrolling. Texto largo.
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
lcd.begin(16, 2);
lcd.print("INICIANDO");
delay(1000);
}
void loop() {
String mensaje = "Esternocleidomastoideo";
for (int i = 0; i < 16; i++) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(mensaje.substring(i, i + 16)); // Muestra 16 caracteres a la vez
delay(250);
}
}
PA 13 02 Display LCD escritura monitor serie.
#include <LiquidCrystal.h>
// Definir pines de conexión del LCD
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
Serial.begin(9600);
lcd.begin(16, 2); // Inicializar LCD 16x2
lcd.print("Esperando...");
}
void loop() {
if (Serial.available()) {
lcd.clear();
String mensaje = Serial.readStringUntil('\n'); // Leer hasta nueva línea
lcd.setCursor(0, 0);
lcd.print(mensaje);
}
}
PA 13 03 Display LCD escritura monitor serie. Texto largo.
#include <LiquidCrystal.h>
// Definir pines de conexión del LCD (modo paralelo)
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
Serial.begin(9600);
lcd.begin(16, 2); // Inicializar LCD 16x2
lcd.print("Esperando...");
}
void loop() {
if (Serial.available()) {
lcd.clear();
String mensaje = Serial.readStringUntil('\n'); // Leer hasta nueva línea
mostrarTextoDesplazado(mensaje);
}
}
// Función para desplazar texto si es mayor a 16 caracteres
void mostrarTextoDesplazado(String texto) {
int longitud = texto.length();
if (longitud <= 16) {
lcd.setCursor(0, 0);
lcd.print(texto); // Si el texto cabe, se muestra directamente
} else {
for (int i = 0; i <= longitud - 16; i++) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(texto.substring(i, i + 16)); // Mostrar 16 caracteres
delay(300); // Ajusta la velocidad del desplazamiento
}
}
}
PA 13 04 Display LCD valor potenciómetro.
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int potPin = A0;
int valorPot = 0;
void setup() {
lcd.begin(16, 2);
lcd.print("INICIANDO");
delay(1000);
}
void loop() {
valorPot = analogRead(potPin);
lcd.setCursor(0, 0);
lcd.print("Potenciometro:");
lcd.setCursor(0, 1);
lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print("Valor: ");
lcd.print(valorPot);
delay(100);
}