/*************************************************************
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 "TMPxxxxxx"
#define BLYNK_TEMPLATE_NAME "Device"
#define BLYNK_AUTH_TOKEN "hdLnMtkv4tGne2zOUlm6IaeZ80zUWMd-"
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
//
int pinValue;
int pinValue1;
int pinValue2;
#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)
{
pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
Serial.println(pinValue);
// process received value
}
BLYNK_WRITE(V1)
{
pinValue1 = param.asInt(); // assigning incoming value from pin V1 to a variable
Serial.println(pinValue1);
// process received value
}
BLYNK_WRITE(V2)
{
pinValue2 = param.asInt(); // assigning incoming value from pin V1 to a variable
Serial.println(pinValue2);
// process received value
}
void setup()
{
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(18, OUTPUT);
// 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);
}
void loop()
{
Blynk.run();
if(pinValue ==1){
digitalWrite(4, HIGH);
delay(10);
}else{
digitalWrite(4, LOW);
}
if(pinValue1 ==1){
digitalWrite(5, HIGH);
delay(10);
}else{
digitalWrite(5, LOW);
}
if(pinValue2 ==1){
digitalWrite(18, HIGH);
delay(10);
}else{
digitalWrite(18, LOW);
}
}
esp:VIN
esp:GND.2
esp:D13
esp:D12
esp:D14
esp:D27
esp:D26
esp:D25
esp:D33
esp:D32
esp:D35
esp:D34
esp:VN
esp:VP
esp:EN
esp:3V3
esp:GND.1
esp:D15
esp:D2
esp:D4
esp:RX2
esp:TX2
esp:D5
esp:D18
esp:D19
esp:D21
esp:RX0
esp:TX0
esp:D22
esp:D23
led1:A
led1:C
led2:A
led2:C
led3:A
led3:C