Codigo Arduino
Codigo Arduino
// Textos
String texto_fila = "Feliz Navidad Ha nacido Jesus";
void setup() {
pinMode(RED, OUTPUT);
pinMode(GREEN, OUTPUT);
pinMode(BLUE, OUTPUT);
digitalWrite(RED, HIGH);
digitalWrite(GREEN, LOW);
digitalWrite(BLUE, LOW);
pinMode(ROJO, OUTPUT);
pinMode(VERDE, OUTPUT);
pinMode(AZUL, OUTPUT);
digitalWrite(ROJO, HIGH);
digitalWrite(VERDE, LOW);
digitalWrite(AZUL, LOW);
myservo.attach(3);
myservo.write(0);// move servos to center position -> 90°
// Configuración monitor serie
Serial.begin(9600);
lcd.begin(COLS, ROWS); // Configuramos las filas y las columnas del LCD en este
caso 16 columnas y 2 filas
}
int redValue;
int greenValue;
int blueValue;
int rojoValue;
int verdeValue;
int azulValue;
void loop() {
#define delayTime 10 // fading time between colors
redValue = 255; // choose a value between 1 and 255 to change the color.
greenValue = 0;
blueValue = 0;
rojoValue = 255; // choose a value between 1 and 255 to change the color.
verdeValue = 0;
azulValue = 0;
// this is unnecessary as we've either turned on RED in SETUP
// or in the previous loop ... regardless, this turns RED off
// analogWrite(RED, 0);
// delay(1000);
for(int i = 0; i < 255; i += 1) // fades out red bring green full when i=255
{
redValue -= 1;
rojoValue -= 1;
greenValue += 1;
verdeValue += 1;
// The following was reversed, counting in the wrong directions
// analogWrite(RED, 255 - redValue);
// analogWrite(GREEN, 255 - greenValue);
analogWrite(RED, redValue);
analogWrite(ROJO, rojoValue);
analogWrite(GREEN, greenValue);
analogWrite(VERDE, verdeValue);
delay(delayTime);
}
redValue = 0;
greenValue = 255;
blueValue = 0;
rojoValue = 0;
verdeValue = 255;
azulValue = 0;
for(int i = 0; i < 255; i += 1) // fades out green bring blue full when i=255
{
greenValue -= 1;
verdeValue -= 1;
blueValue += 1;
azulValue += 1;
// The following was reversed, counting in the wrong directions
// analogWrite(GREEN, 255 - greenValue);
// analogWrite(BLUE, 255 - blueValue);
analogWrite(GREEN, greenValue);
analogWrite(VERDE, verdeValue);
analogWrite(BLUE, blueValue);
analogWrite(AZUL, azulValue);
delay(delayTime);
}
redValue = 0;
greenValue = 0;
blueValue = 255;
rojoValue = 0;
verdeValue = 0;
azulValue = 255;
for(int i = 0; i < 255; i += 1) // fades out blue bring red full when i=255
{
// The following code has been rearranged to match the other two similar
sections
blueValue -= 1;
azulValue -= 1;
redValue += 1;
rojoValue += 1;
// The following was reversed, counting in the wrong directions
// analogWrite(BLUE, 255 - blueValue);
// analogWrite(RED, 255 - redValue);
analogWrite(BLUE, blueValue);
analogWrite(AZUL, azulValue);
analogWrite(RED, redValue);
analogWrite(ROJO, rojoValue);
delay(delayTime);
}
int tam_texto=texto_fila.length();// Obtenemos el tamaño del texto
// Limpiamos pantalla
lcd.clear();
//Situamos el cursor
lcd.setCursor(0, 0);
// Escribimos el texto
lcd.print(texto);
// Esperamos
delay(VELOCIDAD);
}
//Situamos el cursor
lcd.setCursor(i, 1);
// Escribimos el texto
lcd.print(texto_fila);
// Esperamos
delay(VELOCIDAD);
}
// Limpiamos pantalla
lcd.clear();
//Situamos el cursor
lcd.setCursor(0, 1);
// Escribimos el texto
lcd.print(texto);
// Esperamos
delay(VELOCIDAD);
}
}