#define ledRed 14
#define ledYellow 12
#define ledGreen 13
#define BLYNK_TEMPLATE_ID "TMPL6dfOtTxQY"
#define BLYNK_TEMPLATE_NAME "Led"
#define BLYNK_AUTH_TOKEN "vYwkCc2s9UBNJQDivJj3TCvvLA3rEIhc"
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = BLYNK_AUTH_TOKEN;
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Wokwi-GUEST"; //nama hotspot yang digunakan
char pass[] = ""; //password hotspot yang digunakan
BLYNK_WRITE(V0)
{
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
pinMode(14, OUTPUT);
}
BLYNK_WRITE(V1)
{
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
}
BLYNK_WRITE(V2)
{
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
}
void setup() {
pinMode(14, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
Blynk.begin(auth, ssid, pass);
}
void loop() {
Blynk.run();
// Lampu merah menyala selama 2 detik
digitalWrite(ledRed, HIGH);
digitalWrite(ledYellow, LOW);
digitalWrite(ledGreen, LOW);
delay(2000);
// Lampu kuning menyala selama 2 detik
digitalWrite(ledRed, LOW);
digitalWrite(ledYellow, HIGH);
digitalWrite(ledGreen, LOW);
delay(2000);
// Lampu hijau menyala selama 2 detik
digitalWrite(ledRed, LOW);
digitalWrite(ledYellow, LOW);
digitalWrite(ledGreen, HIGH);
delay(2000);
}