#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "TMPL62tVVvHrw"
#define BLYNK_TEMPLATE_NAME "Kontrol RGB"
#define BLYNK_AUTH_TOKEN "dE5r_H6yochohhTHR-btlnFqhNqPN3Jx"
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
// Replace these with your Blynk authentication token and Wi-Fi credentials
char auth[] = "dE5r_H6yochohhTHR-btlnFqhNqPN3Jx";
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
// Define the pin numbers for the RGB LED
const int redPin = 5; // GPIO5
const int greenPin = 18; // GPIO18
const int bluePin = 19; // GPIO19
void setup() {
// Set the RGB LED pins as outputs
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
// Connect to Wi-Fi
Blynk.begin(auth, ssid, pass);
// Print the IP address assigned to your ESP32
Serial.begin(115200);
Serial.println(WiFi.localIP());
}
void loop() {
// Run the Blynk service
Blynk.run();
}
// Blynk virtual pin handler for RGB LED control
BLYNK_WRITE(V1) {
// Read the values from the Blynk app (0-255)
int redValue = param[0].asInt();
int greenValue = param[1].asInt();
int blueValue = param[2].asInt();
// Map the values from 0-255 to 0-1023 (for ESP32 PWM)
int redPWM = map(redValue, 0, 255, 0, 1023);
int greenPWM = map(greenValue, 0, 255, 0, 1023);
int bluePWM = map(blueValue, 0, 255, 0, 1023);
// Set the RGB LED colors using PWM
analogWrite(redPin, redPWM);
analogWrite(greenPin, greenPWM);
analogWrite(bluePin, bluePWM);
}