#define BLYNK_TEMPLATE_ID "TMPL3hE5wst8X"
#define BLYNK_TEMPLATE_NAME "Home automatio"
#define BLYNK_AUTH_TOKEN "lmHNsWo01aJ_dDGAcsJUEmlM6Fw6rQsW"
// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
char auth[] = BLYNK_AUTH_TOKEN;
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
#define LED1 2
int SW_State_R = 0;
BLYNK_WRITE (button1_vpin)
{
SW_State_R = param.asInt();
if (SW_State_R == 1)
{
digitalWrite(LED1, HIGH);
Serial.println("RED ON");
Blynk.virtualWrite(V1, HIGH);
}
else
{
digitalWrite(LED1, LOW);
Serial.println("RED OFF");
Blynk.virtualWrite(V1, LOW);
}
}
void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(36,INPUT);
pinMode(LED1,OUTPUT);
//digitalWrite(2,HIGH); //PULL_UP Resistor
Blynk.begin(auth, ssid, pass);
}
void loop()
{
// put your main code here, to run repeatedly:
Blynk.run();
if(digitalRead(35) == HIGH)
{
digitalWrite(LED1,HIGH);
//Serial.println("Motion Detected");
}
else
{
digitalWrite(LED1,LOW);
//Serial.println("No Motion");
}
delay(500);
}