/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "TMPL6LvD-qmTu"
#define BLYNK_TEMPLATE_NAME "SMARTHOME"
#define BLYNK_AUTH_TOKEN "k-sgtViODRwetlNgZPZs7nLv3HHX0_zx"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Wokwi-GUEST" ;
char pass[] = "";
BLYNK_WRITE(V0) // Executes when the value of virtual pin 0 changes
{
if(param.asInt() == 1)
{
// execute this code if the switch widget is now ON
digitalWrite(4,HIGH); // Set digital pin 2 HIGH
}
else
{
// execute this code if the switch widget is now OFF
digitalWrite(4,LOW); // Set digital pin 2 LOW
}
}
BLYNK_WRITE(V1) // Executes when the value of virtual pin 0 changes
{
if(param.asInt() == 1)
{
// execute this code if the switch widget is now ON
digitalWrite(16,HIGH); // Set digital pin 2 HIGH
}
else
{
// execute this code if the switch widget is now OFF
digitalWrite(16,LOW); // Set digital pin 2 LOW
}
}
void setup()
{
// Debug console
Serial.begin(9600);
pinMode(4, OUTPUT); // Initialise digital pin 2 as an output pin
pinMode(16, OUTPUT); // Initialise digital pin 2 as an output pin
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
}
void loop()
{
Blynk.run();
int sensor = random(0,100);
Blynk.virtualWrite(V2,sensor);
}