#define BLYNK_TEMPLATE_ID "TMPL6Mqx79Ydl"
#define BLYNK_TEMPLATE_NAME "NURSE CALL"
#define BLYNK_AUTH_TOKEN "ev8J-aFmYDLwJX86jmEwKL7aCDc2neTR"
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
const byte button_R1_pin = 23;
const byte button_R2_pin = 22;
const byte button_R3_pin = 21;
const byte button_R4_pin = 19;
const byte button_R5_pin = 18;
const byte button_R6_pin = 5;
byte last_button_state_R1 = HIGH;
byte last_button_state_R2 = HIGH;
byte last_button_state_R3 = HIGH;
byte last_button_state_R4 = HIGH;
byte last_button_state_R5 = HIGH;
byte last_button_state_R6 = HIGH;
void setup()
{
Serial.begin(115200);
pinMode(button_R1_pin, INPUT_PULLUP);
pinMode(button_R2_pin, INPUT_PULLUP);
pinMode(button_R3_pin, INPUT_PULLUP);
pinMode(button_R4_pin, INPUT_PULLUP);
pinMode(button_R5_pin, INPUT_PULLUP);
pinMode(button_R6_pin, INPUT_PULLUP);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
}
void handle_button(byte button_pin, byte &last_button_state, int virtual_pin)
{
byte reading = digitalRead(button_pin);
if (reading != last_button_state && reading == LOW)
Blynk.virtualWrite(virtual_pin, 1);
last_button_state = reading;
}
void loop()
{
handle_button(button_R1_pin, last_button_state_R1, V1);
handle_button(button_R2_pin, last_button_state_R2, V2);
handle_button(button_R3_pin, last_button_state_R3, V3);
handle_button(button_R4_pin, last_button_state_R4, V4);
handle_button(button_R5_pin, last_button_state_R5, V5);
handle_button(button_R6_pin, last_button_state_R6, V6);
Blynk.run();
}