/*************************************************************
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 "TMPL6TY3UPoQ9"
#define BLYNK_TEMPLATE_NAME "tugas no 5 job 3 new"
#define BLYNK_AUTH_TOKEN "1NXWOL3UykQgBnvnErNqX1A79on1fcPQ"
/* 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 pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
if(pinValue==1){digitalWrite(2,HIGH);}else{digitalWrite(2, LOW);}
//proces received value
}
BLYNK_WRITE(V1)
{
int pinValue = param.asInt();
if(pinValue==1){digitalWrite(4, HIGH);}else{digitalWrite(4,LOW);}
//proces received value
}
BLYNK_WRITE(V2)
{
int pinValue = param.asInt();
if(pinValue==1){digitalWrite(18, HIGH);}else{digitalWrite(18, LOW);}
//proces received value
}
BLYNK_WRITE(V3)
{
int pinValue = param.asInt();
if(pinValue==1){digitalWrite(19,HIGH);}else{digitalWrite(19, LOW);}
//proces received value
}
void setup()
{
pinMode(2, OUTPUT);
pinMode(4, OUTPUT);
pinMode(18, OUTPUT);
pinMode(19, OUTPUT);
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);
}
void loop()
{
Blynk.run();
}