#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int buttonPin = 2;
const int buzzerPin = 3;
const int questionCount = 5;
int score = 0;
String questions[5] = {
“Did you drink 4 cups of water today?”,
“Did you eat 1 fruit today?”,
“Did you sleep 7 hours last night?”,
“Did you walk 15 minutes today?”,
“Did you avoid junk food today?”
};
void setup() {
lcd.init();
lcd.backlight();
pinMode(buttonPin, INPUT_PULLUP);
pinMode(buzzerPin, OUTPUT);
welcomeMessage();
}
void loop() {
score = 0;
for (int i = 0; i < questionCount; i++) {
lcd.clear();
scrollQuestion(questions[i]);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Answer YES?”);
lcd.setCursor(0, 1);
lcd.print(“Press in 5 sec”);
bool answeredYes = false;
unsigned long startTime = millis();
while (millis() – startTime < 5000) {
if (digitalRead(buttonPin) == LOW) {
answeredYes = true;
beep();
score += 2;
break;
}
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Answer: “);
lcd.print(answeredYes ? “YES” : “NO”);
delay(1500);
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Score: ” + String(score) + “/10”);
lcd.setCursor(0, 1);
if (score > 5) {
lcd.print(“Great Job!”);
successTone();
} else {
lcd.print(“Keep Trying!”);
motivationTone();
}
delay(5000);
asm volatile (“jmp 0”); // Restart
}
void scrollQuestion(String text) {
int len = text.length();
for (int i = 0; i <= len – 1; i++) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(text.substring(i, i + 16));
delay(300);
}
delay(1000);
}
void welcomeMessage() {
lcd.setCursor(0, 0);
lcd.print(“Daily Health”);
lcd.setCursor(0, 1);
lcd.print(“Check Starting…”);
beep();
delay(2000);
lcd.clear();
}
void beep() {
digitalWrite(buzzerPin, HIGH);
delay(100);
digitalWrite(buzzerPin, LOW);
}
void successTone() {
for (int i = 0; i < 3; i++) {
beep();
delay(150);
}
}
void motivationTone() {
digitalWrite(buzzerPin, HIGH);
delay(300);
digitalWrite(buzzerPin, LOW);
}