#include <SD.h>
#define CS_PIN 5
char dato [40] = "";
byte hora, minuto, seg, dia ;
bool estado = false;
String td = " PM";
void setup() {
Serial.begin(115200);
if (!SD.begin(CS_PIN)) {
Serial.println("ERROR EN SD!");
while (true);
}
Serial.println("INICIO CORRECTO.");
// Example of reading file from the card:
File textFile = SD.open("/wokwi.txt");
if (textFile) {
while (textFile.available()) {
dato [40] = Serial.write(textFile.read());
}
Serial.println(dato);
textFile.close();
} else {
Serial.println("error opening wokwi.txt!");
}
hora = 12;
minuto = 58;
seg = 40;
dia =0;
estado = true;
td = " AM";
Serial.println(dia);
}
void loop() {
delay(100);
seg++;
if(seg>=60){
minuto++;
seg = 0;
}
if(minuto>=60){
minuto = 0;
hora++;
}
if(hora>=13){
hora = 1;
if(estado){
td= " PM";
}
else{
td= " AM";
dia ++;
Serial.println(dia);
}
}
Serial.println("HORA :" + String(hora)+ " - "+ String(minuto)+ " - "+ String(seg) + td);
}