Created
March 21, 2022 00:22
-
-
Save chepecarlos/95b02bc9759ebe848351c526bc1d3d7d to your computer and use it in GitHub Desktop.
Codigo de Ejemplos de Fechas
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
int Siglo = 6, Anno_4 = 5, Anno_7 = 1; | |
int Suma, Modulo; | |
int Dia, Mes; | |
int clave; | |
const int EsperaLed = 3000; | |
#define CantidadLed 7 | |
const int claveMes[12] = {0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5}; | |
const int Led[CantidadLed] = {8, 7, 6, 5, 4, 3, 2}; | |
const String NombreDia[7] = {"Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sabado"}; | |
void setup() { | |
Serial.begin(9600); | |
for (int i; i < CantidadLed; i++) { | |
pinMode(Led[i], OUTPUT); | |
} | |
Serial.println("Bienvenido"); | |
} | |
void Decodificador() { | |
String Mensaje = Serial.readStringUntil('\n'); | |
Serial.print("TU FECHA ES "); | |
Serial.println(Mensaje); // 20/1\n | |
int PocicionDiagonal = Mensaje.indexOf('/'); | |
int PocicionSaltoLinea = Mensaje.length(); | |
Dia = Mensaje.substring(0, PocicionDiagonal).toInt(); | |
Mes = Mensaje.substring(PocicionDiagonal + 1, PocicionSaltoLinea).toInt(); | |
Serial.print(" Dia : "); | |
Serial.print(Dia); | |
Serial.print(" Mes : "); | |
Serial.println(Mes); | |
} | |
void loop() { | |
if (Serial.available()) { | |
Decodificador(); | |
clave = claveMes[Mes - 1]; | |
Suma = Dia + clave + Siglo + Anno_4 + Anno_7; | |
Modulo = Suma % 7; | |
EndenderLed(Modulo); | |
} | |
} | |
void EndenderLed(int Indice) { | |
Serial.print("Tu dia es "); | |
Serial.println(NombreDia[Indice]); | |
digitalWrite(Led[Indice], HIGH); | |
delay(EsperaLed); | |
digitalWrite(Led[Indice], LOW); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Gracias :)