const int LED_YELLOW = 3;
const int LED_ORANGE = 5;
const int LED_WHITE = 11;
const int rgbRed = 13;
const int rgbGreen = 10;
const int rgbBlue = 7;
const int potentiometer = A0;
void setup() {
// put your setup code here, to run once:
pinMode(LED_YELLOW, OUTPUT);
pinMode(LED_ORANGE, OUTPUT);
pinMode(LED_WHITE, OUTPUT);
pinMode(rgbRed, OUTPUT);
pinMode(rgbGreen, OUTPUT);
pinMode(rgbBlue, OUTPUT);
Serial.begin(9000);
}
void loop() {
int potValue = analogRead(potentiometer);
int intensity = map(potValue, 125, 36, 0, 1);
Serial.println(potValue);
delay(1000);
digitalWrite(3, HIGH);
digitalWrite(5, LOW);
digitalWrite(11, LOW);
delay(1000);
digitalWrite(5, HIGH);
digitalWrite(3, LOW);
digitalWrite(11, LOW);
delay(1000);
digitalWrite(11, HIGH);
digitalWrite(3, LOW);
digitalWrite(5, LOW);
analogWrite(rgbRed, intensity);
analogWrite(rgbGreen, intensity);
analogWrite(rgbBlue, intensity);
setcolor(150, 0, 0);
delay(1000);
setcolor(0, 255, 0);
delay(1000);
setcolor(0, 0, 255);
delay(1000);
}
void setcolor(int red, int green, int blue) {
// Invert color values because of common anode RGB LED
red = 255 - red;
green = 255 - green;
blue = 255 - blue;
// Write color values to LED pins
analogWrite(rgbRed, red);
analogWrite(rgbGreen, green);
analogWrite(rgbBlue, blue);
}