// Define Pulse Width Modulation (PWM) enabled pins
const int redPin = 11;
const int greenPin = 10;
const int bluePin = 9;
void setup() {
// put your setup code here, to run once:
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
// Cycle through basic sample colors
setColor(255, 0, 0); // Pure Red
delay(1000);
setColor(0, 255, 0); // Pure Green
delay(1000);
setColor(0, 0, 255); // Pure Blue
delay(1000);
setColor(255, 255, 0); // Yellow (Red + Green)
delay(1000);
setColor(80, 0, 80); // Purple
delay(1000);
}
// Defining the custom function behavior
void setColor(int redValue, int greenValue, int blueValue) {
analogWrite(redPin, redValue);
analogWrite(greenPin, greenValue);
analogWrite(bluePin, blueValue);
}