Método para guardar archivos en la SD CARD:
void logCard() {
digitalWrite(CS_SD,LOW);
myFile=SD.open("DATA.txt", FILE_WRITE);
if (myFile) {
Serial.println("File opened ok");
myFile.print(uidString);
myFile.print(", ");
DateTime now = rtc.now();
myFile.print(now.year(), DEC);
myFile.print('/');
myFile.print(now.month(), DEC);
myFile.print('/');
myFile.print(now.day(), DEC);
myFile.print(',');
myFile.print(now.hour(), DEC);
myFile.print(':');
myFile.println(now.minute(), DEC);
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.println(now.minute(), DEC);
Serial.println("sucessfully written on SD card");
myFile.close();
userCheckInHour = now.hour();
userCheckInMinute = now.minute();
}
else {
Serial.println("error opening data.txt");
}
digitalWrite(CS_SD,HIGH);
}
Método para imprimir mensaje genérico en la SD CARD:
void MessageOnLCD(){
lcd.setCursor(0, 0);
lcd.print("ID : ");
lcd.print(uidString);
}
Método para habilitar la apertura de la cerradura eléctica:
void OpeningDoor(){
digitalWrite(SOLENOID , HIGH);
delay(5000);
digitalWrite(SOLENOID , LOW);
delay(5000);
}