#include <LiquidCrystal.h> //incluimos librería
#define COLS 16 // Columnas del LCD // Definimos las constantes
#define ROWS 2 // Filas del LCD
#define VELOCIDAD 500 // Velocidad a la que se mueve el texto
LiquidCrystal lcd(2, 3, 9, 10, 11, 12); //Inicializamos los pines de la placa LCD
String texto_fila = "Dani Osito";
void setup()
{
Serial.begin(9600); // Configuración monitor serie
lcd.begin(COLS, ROWS); // Configuramos las filas y las columnas del LCD
}
void loop()
{
int tam_texto=texto_fila.length(); // Obtenemos el tamaño del texto
for(int i=tam_texto; i>0 ; i--) // Mostramos entrada texto por la izquierda
{
String texto = texto_fila.substring(i-1);
lcd.clear(); // Limpiamos pantalla
lcd.setCursor(0, 0); //Situamos el cursor
lcd.print(texto); // Escribimos el texto
delay(VELOCIDAD); // Esperamos
}
for(int i=1; i<=COLS;i++) // Desplazamos el texto hacia la derecha
{
lcd.clear();// Limpiamos pantalla
lcd.setCursor(i, 0); //Situamos el cursor
lcd.print(texto_fila); // Escribimos el texto
delay(VELOCIDAD); // Esperamos
}
for(int i=COLS;i>=1;i--) // Desplazamos el texto hacia la izquierda en la 2ªfila
{
lcd.clear(); // Limpiamos pantalla
lcd.setCursor(i, 1); //Situamos el cursor
lcd.print(texto_fila); // Escribimos el texto
delay(VELOCIDAD); // Esperamos
}
for(int i=1; i<=tam_texto ; i++)// Mostramos salida del texto por la izquierda
{
String texto = texto_fila.substring(i-1);
lcd.clear();// Limpiamos pantalla
lcd.setCursor(0, 1); //Situamos el cursor
lcd.print(texto); // Escribimos el texto
delay(VELOCIDAD); // Esperamos
}
}