// Pin definitions
#define RED_PIN 0
#define BLUE_PIN 1
#define GREEN_PIN 4
#define BUTTON_PIN 3
// Color values
#define RED_COLOR {255, 0, 0}
#define BLUE_COLOR {0, 0, 255}
#define GREEN_COLOR {0, 255, 0}
#define PURPLE_COLOR {128, 0, 128}
#define YELLOW_GREEN_COLOR {173, 255, 47}
#define ORANGE_COLOR {255, 165, 0}
#define YELLOW_COLOR {255, 255, 0}
#define PINK_COLOR {255, 192, 203}
#define TURQUOISE_COLOR {64, 224, 208}
#define ICE_BLUE_COLOR {173, 216, 230}
// Array of colors
const byte colors[][3] = {
RED_COLOR,
BLUE_COLOR,
GREEN_COLOR,
PURPLE_COLOR,
YELLOW_GREEN_COLOR,
ORANGE_COLOR,
YELLOW_COLOR,
PINK_COLOR,
TURQUOISE_COLOR,
ICE_BLUE_COLOR
};
int currentColor = 0;
void setup() {
pinMode(RED_PIN, OUTPUT);
pinMode(BLUE_PIN, OUTPUT);
pinMode(GREEN_PIN, OUTPUT);
pinMode(BUTTON_PIN, INPUT_PULLUP);
digitalWrite(RED_PIN,1);
digitalWrite(BLUE_PIN,1);
digitalWrite(GREEN_PIN,1);
}
void loop() {
// If the button is pressed, change the color
if (digitalRead(BUTTON_PIN) == LOW) {
currentColor = (currentColor + 1) % (sizeof(colors) / 3);
analogWrite(RED_PIN, 255-colors[currentColor][0]);
analogWrite(GREEN_PIN, 255-colors[currentColor][1]);
analogWrite(BLUE_PIN, 255-colors[currentColor][2]);
delay(500);
}
}