/*********************
This sketch shows how to read values from Virtual Pins
App dashboard setup:
Slider widget (0...100) on Virtual Pin V1
*********************/
/* Fill-in information from Blynk Device Info here */
#define BLYNK_TEMPLATE_ID "TMPL6dQGqokQq"
#define BLYNK_TEMPLATE_NAME "Mengatur Warna Lampu RGB"
#define BLYNK_AUTH_TOKEN "ic7qYbr7F6oChPfcyv1B9GxP4-n131mn"
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
// This function will be called every time Slider Widget
// in Blynk app writes values to the Virtual Pin V1
BLYNK_WRITE(V0)
{
int TOMBOLMERAH = param.asInt(); // assigning incoming value from pin V1 to a variable
if (TOMBOLMERAH==1){
digitalWrite(2, HIGH);}
else{
digitalWrite(2, LOW);
}
// process received value
}
BLYNK_WRITE(V1)
{
int TOMBOLBIRU = param.asInt(); // assigning incoming value from pin V1 to a variable
if (TOMBOLBIRU==1){
digitalWrite(4, HIGH);}
else{
digitalWrite(4, LOW);
}
}
BLYNK_WRITE(V2)
{
int TOMBOLHIJAU = param.asInt(); // assigning incoming value from pin V1 to a variable
if (TOMBOLHIJAU==1){
digitalWrite(5, HIGH);}
else{
digitalWrite(5, LOW);}
}
void setup()
{
// Debug console
Serial.begin(115200);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
// You can also specify server:
//Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
//Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
pinMode(2, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
}
void loop()
{
Blynk.run();
}