/*************************************************************
You’ll need:
- Blynk IoT app (download from App Store or Google Play)
- Arduino Uno board
- Decide how to connect to Blynk
(USB, Ethernet, Wi-Fi, Bluetooth, ...)
There is a bunch of great example sketches included to show you how to get
started. Think of them as LEGO bricks and combine them as you wish.
For example, take the Ethernet Shield sketch and combine it with the
Servo example, or choose a USB sketch and add a code from SendData
example.
*************************************************************/
/* Fill-in information from Blynk Device Info here */
#define BLYNK_TEMPLATE_ID "TMPL6jYsrxPaA"
#define BLYNK_TEMPLATE_NAME "Mengubah Lampu RGB"
#define BLYNK_AUTH_TOKEN "fOVM8uqkTshWDm1i_jNmV7ydNC91tgvO"
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
const int pinR = 3;
const int pinG = 5;
const int pinB = 6;
const int potR = A0;
const int potG = A1;
const int potB = A2;
void setup() {
pinMode(pinR, OUTPUT);
pinMode(pinG, OUTPUT);
pinMode(pinB, OUTPUT);
pinMode(potR, INPUT);
pinMode(potG, INPUT);
pinMode(potB, INPUT);
}
int readPot(int pin) {
return map(analogRead(pin), 0, 1023, 0, 255);
}
void loop() {
analogWrite(pinR, readPot(potR));
analogWrite(pinG, readPot(potG));
analogWrite(pinB, readPot(potB));
}