/*************************************************************
You can use this sketch as a debug tool that prints all incoming values
sent by a widget connected to a Virtual Pin 1 in the Blynk App.
App dashboard setup:
Slider widget (0...100) on V1
*************************************************************/
/* Fill-in information from Blynk Device Info here */
#define BLYNK_TEMPLATE_ID "TMPL6zVYiCUg0"
#define BLYNK_TEMPLATE_NAME "myEsp32"
#define BLYNK_AUTH_TOKEN "4RCymAhvBkp7q_qshwCfy5cI9DV9ygy7"
/* 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[] = "iNoomnim";
char pass[] = "12345678";
// This function will be called every time Slider Widget
// in Blynk app writes values to the Virtual Pin 1
BLYNK_WRITE(V1) {
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
// You can also use:
// String i = param.asStr();
// double d = param.asDouble();
if(pinValue ==1){
digitalWrite(2, HIGH);
delay(1000);
}else{
digitalWrite(2, LOW);
}
Serial.print("V1 Slider value is: ");
Serial.println(pinValue);
}
void setup() {
// Debug console
Serial.begin(115200);
pinMode(2,OUTPUT);
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();
}