Created
January 28, 2021 19:21
-
-
Save jmtexla68/aa4c67831129f97a70a7f27e49f363dc to your computer and use it in GitHub Desktop.
Demostración del uso de un display de 16x2 Este ejemplo imprime un mensaje y va corriendo las dos líneas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
*********************************************** | |
Tutorial Arduino LCD | |
https://conbotassucias.wordpress.com/ | |
*********************************************** | |
Demostracion del uso de un display de 16x2 | |
La libreria LiquidCrystal funciona con todos los | |
displays compatibles con el driver Hitachi HD44780. | |
Este ejemplo imprime un mensaje y va corriendo las dos lineas | |
El circuito: | |
* LCD RS (pin 4) -> pin 12 arduino (digital) | |
* LCD E_nable (pin 6) -> pin 11 arduino (digital) | |
* LCD D4 (pin 11) -> pin 5 arduino | |
* LCD D5 (pin 12) -> pin 4 arduino | |
* LCD D6 (pin 13) -> pin 3 arduino | |
* LCD D7 (pin 14) -> pin 2 arduino | |
* LCD R/W (pin 5) -> tierra | |
* Potenciometro de 10K: | |
* terminales exteriores a +5V y tierra | |
* terminal central a LCD Vo (pin 3) | |
*/ | |
// Incluímos la libreria externa | |
#include <LiquidCrystal.h> // Entre los símbolos <> buscará en la carpeta de librerías configurada | |
// Definimos las constantes | |
#define COLS 16 // Columnas del LCD | |
#define ROWS 2 // Filas del LCD | |
#define VELOCIDAD 300 // Velocidad a la que se mueve el texto | |
// Lo primero is inicializar la librería indicando los pins de la interfaz | |
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); | |
// Textos | |
String texto_fila = "conbotassucias.blog"; | |
void setup() { | |
// Configuración monitor serie | |
Serial.begin(9600); | |
// Configuramos las filas y las columnas del LCD en este caso 16 columnas y 2 filas | |
lcd.begin(COLS, ROWS); | |
} | |
void loop() { | |
// Obtenemos el tamaño del texto | |
int tam_texto=texto_fila.length(); | |
// Mostramos entrada texto por la izquierda | |
for(int i=tam_texto; i>0 ; i--) | |
{ | |
String texto = texto_fila.substring(i-1); | |
// Limpiamos pantalla | |
lcd.clear(); | |
//Situamos el cursor | |
lcd.setCursor(0, 0); | |
// Escribimos el texto | |
lcd.print(texto); | |
// Esperamos | |
delay(VELOCIDAD); | |
} | |
// Desplazamos el texto hacia la derecha | |
for(int i=1; i<=16;i++) | |
{ | |
// Limpiamos pantalla | |
lcd.clear(); | |
//Situamos el cursor | |
lcd.setCursor(i, 0); | |
// Escribimos el texto | |
lcd.print(texto_fila); | |
// Esperamos | |
delay(VELOCIDAD); | |
} | |
// Desplazamos el texto hacia la izquierda en la segunda fila | |
for(int i=16;i>=1;i--) | |
{ | |
// Limpiamos pantalla | |
lcd.clear(); | |
//Situamos el cursor | |
lcd.setCursor(i, 1); | |
// Escribimos el texto | |
lcd.print(texto_fila); | |
// Esperamos | |
delay(VELOCIDAD); | |
} | |
// Mostramos salida del texto por la izquierda | |
for(int i=1; i<=tam_texto ; i++) | |
{ | |
String texto = texto_fila.substring(i-1); | |
// Limpiamos pantalla | |
lcd.clear(); | |
//Situamos el cursor | |
lcd.setCursor(0, 1); | |
// Escribimos el texto | |
lcd.print(texto); | |
// Esperamos | |
delay(VELOCIDAD); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment