// Define Blynk template ID, name, and auth token
#define BLYNK_TEMPLATE_ID "TMPL6pa6NnJjs"
#define BLYNK_TEMPLATE_NAME "ExamAFS"
#define BLYNK_AUTH_TOKEN "xLyF2e3iVQja_xEuLGLsE1e_zhMcUhmh"
#include <BlynkSimpleEsp32.h>
#include <LiquidCrystal.h>
#include <ESP32Servo.h>
#include <WiFi.h>
const char* ssid = "Wokwi-GUEST";
const char* password = ""; // If no password is needed, keep this empty.
// Define pin numbers.
#define BUZZER_PIN 25 // Example buzzer pin.
#define LCD_RS 19
#define LCD_E 23
#define LCD_D4 18
#define LCD_D5 21
#define LCD_D6 5
#define LCD_D7 15
// Create instances for classes.
LiquidCrystal lcd(rs, enable, d4, d5, d6, d7);
Servo myServo; // Create a servo object
int happiness = 50;
int sadness = 50;
BLYNK_WRITE(V0) { /* Start button functionality */ }
BLYNK_WRITE(V1) { /* Feed button functionality */ }
BLYNK_WRITE(V2) { /* Energy button functionality */ }
void sadSoundAlarm() {
tone(BUZZER_PIN, 1000); // Example frequency for the buzzer
}
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password); // Start Wi-Fi connection
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting..."); // Missing quote added
}
Serial.println("Connected!");
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, password);
lcd.begin(16, 2);
myServo.attach(22); // Ensure you use the correct pin for the servo.
}
void loop() {
Blynk.run();
lcd.setCursor(0, 0); // Set cursor at row=0 col=0 on display
lcd.print("Hap:");
lcd.print(happiness);
lcd.setCursor(8, 0); // Set cursor at row=0 col=8 on display
lcd.print("Sad:");
lcd.print(sadness);
Blynk.virtualWrite(V3, happiness); // Update happiness value on app continuously based on changes in values.
Blynk.virtualWrite(V4, sadness);
}