#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "TMPL6Blzkec7"
#define BLYNK_TEMPLATE_NAME "IoT traffic light"
#define BLYNK_AUTH_TOKEN "5mQlleneL65xKTBQO6pCVrWIcdFME8Ne"
#define Merah 12
#define Kuning 27
#define Hijau 25
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
BlynkTimer timer;
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
int pinValue0=0;
int pinValue1=0;
int pinValue2=0;
BLYNK_WRITE(V0)
{ pinValue0=param.asInt();
if (pinValue0==1)
{
digitalWrite(Merah, HIGH);
}
else{
digitalWrite(Merah, LOW);
}
}
BLYNK_WRITE(V1)
{ pinValue1=param.asInt();
if (pinValue1==1)
{
digitalWrite(Kuning, HIGH);
}
else{
digitalWrite(Kuning, LOW);
}
}
BLYNK_WRITE(V2)
{ pinValue2==param.asInt();
if (pinValue2==1)
{
digitalWrite(Hijau, HIGH);
}
else{
digitalWrite(Hijau, LOW);
}
}
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
pinMode(Merah,OUTPUT);
pinMode(Kuning,OUTPUT);
pinMode(Hijau,OUTPUT);
}
void loop()
{
Blynk.run();
timer.run();
}