// Learn about the ESP32 WiFi simulation in
// https://docs.wokwi.com/guides/esp32-wifi
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C LCD = LiquidCrystal_I2C(0x27, 16, 2);
const int ldr = 33; // LDR (Light Dependent Resistor)
#include <time.h>
int secondes = 0;
int minutes = 0;
int heures = 12; // Commencez à midi par exemple
int jour = 1;
int mois = 1;
int annee = 2024;
unsigned long previousMillis = 0; // Pour stocker le dernier temps enregistré
const long interval = 1000; // Intervalle d'une seconde
void setup() {
Serial.begin(115200);
LCD.init();
LCD.backlight();
LCD.setCursor(0, 0);
LCD.print("Connecting to ");
LCD.setCursor(0, 1);
LCD.print("WiFi ");
delay(1000);
LCD.clear();
LCD.setCursor(0, 0);
LCD.println("Online");
LCD.setCursor(0, 1);
LCD.println("Updating time...");
pinMode(25, INPUT_PULLDOWN);
pinMode(26, INPUT_PULLDOWN);
pinMode(27, INPUT_PULLDOWN);
}
void loop() {
}
/*
// C:\Users\allam\Downloads\babySEATer.ino
String Week[7] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
const char* lyrics[] = {"Hey,", "diddle,", "diddle,", "The cat",
"and", "the fiddle,", "The cow", "jumped",
"over", "the moon.", "The little dog", "laughed",
"to", "see", "such sport,", "And",
"the dish", "ran away", "with the spoon."
};
const int lyricsSize = sizeof(lyrics) / sizeof(char*);
int lyricsIdx = 0;
//States:
#define STATE_START 10
#define STATE_BABY_IN_THE_CAR 20
#define STATE_DRIVING 30
#define STATE_PARENT_LEFT_THE_CAR 40
#define STATE_ALERT_BABY_FORGOTTEN 50
//Global variables:
int state = STATE_START;
int handleStart() {
int nextState;
nextState = STATE_BABY_IN_THE_CAR;
LCD.clear();
LCD.setCursor(0, 1);
LCD.println("BABY_IN_THE_CAR");
return nextState;
};
int handleBabyInTheCar() {
int nextState;
nextState = STATE_DRIVING;
LCD.clear();
LCD.setCursor(0, 1);
LCD.println("DRIVING");
return nextState;
};
int handleDriving() {
int nextState;
nextState = STATE_PARENT_LEFT_THE_CAR;
LCD.clear();
LCD.setCursor(0, 1);
LCD.println("PARENT_LEFT_THE_CAR");
return nextState;
};
int checkIfParentForgotTheBaby() {
int nextState;
nextState = STATE_ALERT_BABY_FORGOTTEN;
LCD.clear();
return nextState;
};
int alertBabyIsForgotten() {
int nextState;
nextState = STATE_BABY_IN_THE_CAR;
return nextState;
};
int sensorValue;
void loop() {
int puerto1 = digitalRead(25);
if (puerto1 == HIGH)
{
switch (state) {
case STATE_START:
state = handleStart();
break;
case STATE_BABY_IN_THE_CAR:
state = handleBabyInTheCar();
break;
case STATE_DRIVING:
state = handleDriving();
break;
case STATE_PARENT_LEFT_THE_CAR:
state = checkIfParentForgotTheBaby();
break;
case STATE_ALERT_BABY_FORGOTTEN:
state = alertBabyIsForgotten();
break;
}
Serial.println(state);
}
sensorValue = analogRead(ldr); // needs about 100 us
delayMicroseconds(30); // delay about 30 us
LCD.clear();
LCD.setCursor(10, 0);
LCD.println(sensorValue);
int click1 = digitalRead(28);
if (click1 == HIGH)
{
Serial.println("Puerto 25 pulsado");
LCD.clear();
LCD.setCursor(10, 0);
LCD.println("Online");
LCD.setCursor(0, 1);
LCD.println("Updating port25...");
}
int puerto2 = digitalRead(26);
if (puerto2 == HIGH)
{
Serial.println("Puerto 26 pulsado");
LCD.clear();
LCD.setCursor(0, 0);
LCD.println("Online");
LCD.setCursor(0, 1);
LCD.println("Updating port26...");
}
int puerto3 = digitalRead(27);
if (puerto3 == HIGH)
{
Serial.println("Puerto 27 pulsado");
}
delay(100);
}
*/