#define BLYNK_TEMPLATE_ID "TMPL6cS4NTo9p"
#define BLYNK_TEMPLATE_NAME "Smart Bulb"
#define BLYNK_AUTH_TOKEN "bqa_mFuF59IsMpjJQuXhk4gmGXcIkYir"
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
char auth[] = BLYNK_AUTH_TOKEN ; //Auth Token
char ssid[] = "Wokwi-GUEST"; //nama hotspot yang digunakan
char pass[] = ""; //password hotspot yang digunakan
const int redPin = 13;
const int greenPin = 12;
const int bluePin = 14;
int red,green,blue = 0;
void setup()
{
Serial.begin(115200);
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
Blynk.begin(auth, ssid, pass);
}
int all = 0;
void loop()
{
Blynk.run();
setColor();
if (red and green or red and blue or green and blue or red and blue and green){
all = 1;
}else {
all = 0;
}
Blynk.virtualWrite(V3,all);
}
BLYNK_WRITE(V0) // Button for Red
{
int redValue = param.asInt();
if (redValue == 1) {
red = 255;
}else {
red = 0;
}
}
BLYNK_WRITE(V1) // Button for Green
{
int greenValue = param.asInt();
if (greenValue == 1) {
green = 255;
}else {
green = 0;
}
}
BLYNK_WRITE(V2) // Button for Blue
{
int blueValue = param.asInt();
if (blueValue == 1) {
blue = 255;
}else {
blue = 0;
}
}
void setColor()
{
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
}