#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "TMPL6y399H9OK"
#define BLYNK_TEMPLATE_NAME "ESP32 V1"
#define BLYNK_AUTH_TOKEN "ioj8O3_dCtz8gpnr3Fso75i8xfK587Jq"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
const int green1 = 4;
const int red1 = 2;
const int track1 = 13;
const int green2 = 17;
const int red2 = 16;
const int track2 = 14;
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
BlynkTimer timer;
void setup() {
// initialize the green pin as an output:
pinMode(green1, OUTPUT);
pinMode(red1, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(track1, INPUT);
// initialize the green pin as an output:
pinMode(green2, OUTPUT);
pinMode(red2, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(track2, INPUT);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
timer.setInterval(1000L, sendData);
}
void loop()
{
Blynk.run();
timer.run();
}
void sendData()
{
String textStatus;
int state1 = 0;
// read the state of the pushbutton value:
state1 = digitalRead(track1);
int state2 = 0;
// read the state of the pushbutton value:
state2 = digitalRead(track2);
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (state1 == HIGH) {
// red aspect on "stop":
digitalWrite(red1, HIGH);
digitalWrite(green1, LOW);
textStatus = "Occupaid";
Blynk.virtualWrite(V0, textStatus);
}
else
{
// green aspect on "proceed":
digitalWrite(green1, HIGH);
digitalWrite(red1, LOW);
textStatus = "Clear";
Blynk.virtualWrite(V0, textStatus);
}
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (state2 == HIGH) {
// red aspect on "stop":
digitalWrite(red2, HIGH);
digitalWrite(green2, LOW);
textStatus = "Occupaid";
Blynk.virtualWrite(V1, textStatus);
}
else
{
// green aspect on "proceed":
digitalWrite(green2, HIGH);
digitalWrite(red2, LOW);
textStatus = "Clear";
Blynk.virtualWrite(V1, textStatus);
}
}