#define BLYNK_TEMPLATE_ID "TMPL382jwNISE"
#define BLYNK_TEMPLATE_NAME "IOT 2"
#define BLYNK_AUTH_TOKEN "yyAjzBem2nqEJHSkalrtHJ4nzdQaRW0i"
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
// Your WiFi credentials.
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
int LedIntensity = 0;
BlynkTimer timer;
// This function is called every time the Virtual Pin 0 state changes
BLYNK_WRITE(V0)
{
Serial.println("Inside Blynk Write");
int slideValue = param.asInt();
LedIntensity = map(slideValue, 0, 100, 0, 255);
ledcWrite(0, LedIntensity); // Update LED intensity directly
}
// This function is called every time the device is connected to the BLYNK_CONNECTED()
BLYNK_CONNECTED() {
Blynk.syncVirtual(V0);
Serial.println("Inside Blynk Connected");
}
void setup()
{
// Debug console
Serial.begin(115200);
Serial.println("Serial Prints Starts...");
// Configure LED PWM functionalitites
ledcSetup(0, 5000, 8); // Channel 0, 5 kHz, 8-bit resolution
ledcAttachPin(21, 0); // GPIO 21 as the PWM pin
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
}
void loop()
{
Blynk.run();
timer.run();
}