const int potPinRed = 34; // Pin untuk potensiometer merah
const int potPinGreen = 35; // Pin untuk potensiometer hijau
const int potPinBlue = 32; // Pin untuk potensiometer biru
const int ledPinRed = 19; // Pin untuk LED merah
const int ledPinGreen = 18; // Pin untuk LED hijau
const int ledPinBlue = 5; // Pin untuk LED biru
void setup() {
Serial.begin(115200);
Serial.println("hay.Billy");
pinMode(ledPinRed, OUTPUT);
pinMode(ledPinGreen, OUTPUT);
pinMode(ledPinBlue, OUTPUT);
}
void loop() {
// Baca nilai potensiometer
int potValueRed = analogRead(potPinRed);
int potValueGreen = analogRead(potPinGreen);
int potValueBlue = analogRead(potPinBlue);
// Konversi nilai potensiometer ke rentang 0-255
int brightnessRed = map(potValueRed, 0, 4095, 0, 255);
int brightnessGreen = map(potValueGreen, 0, 4095, 0, 255);
int brightnessBlue = map(potValueBlue, 0, 4095, 0, 255);
// Atur intensitas warna RGB
analogWrite(ledPinRed, brightnessRed);
analogWrite(ledPinGreen, brightnessGreen);
analogWrite(ledPinBlue, brightnessBlue);
Serial.print("Red : ");
Serial.println(brightnessRed);
Serial.print("Green: ");
Serial.println(brightnessGreen);
Serial.print("Blue: ");
Serial.println(brightnessBlue);
delay(1000); // Delay kecil untuk mengurangi kecepatan pembacaan potensiometer
}