// Define Blynk template ID, name, and auth token
#define BLYNK_TEMPLATE_ID "TMPL6B_2OSJxz"
#define BLYNK_TEMPLATE_NAME "Q1Exam"
#define BLYNK_AUTH_TOKEN "-6JiKImZuG5W8qFzvo65Ai0iaBraUYNR"
#include <BlynkSimpleEsp32.h>
#include <LiquidCrystal.h>
#include <ESP32Servo.h>
#include <WiFiClient.h>
#include <WiFi.h>
char ssid = "Wokwi-GUEST";
char pass = ""; // 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(LCD_RS, LCD_E, LCD_D4, LCD_D5, LEDC_CHANNEL_NA); // ensure correct pins from hardware.
Servo myServo Happiness & sadness levels initialization.
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,HIGH);
}
void setup() {
Serial.begin(115200);
WiFi.begin(ssid,password); // Start Wi-Fi connection
while (WiFi.status() != WL_CONNECTED){
delay(1000);
Serial.println("Connecting }
Serial.println("Connected!");
Blynk.begin(BLYNK_AUTH_TOKEN , ssid ,pass);
lcd.begin();
myServo.attach(D22);
}
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);
}