So I'm new to the world of Arduino, and I'm trying to write a code to make an RGB led blink through the colors of the rainbow. Whenever I try to make it blink multiple colors though, it just blinks red. This is the code I'm using :
int redPin = 11;
int greenPin = 10;
int bluePin = 9;
void setup(){
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
void loop() {
delay(300);
setColor(255, 0, 0);
delay(1000);
setColor(0, 255, 0);
delay(1000);
setColor(0, 0, 255);
delay(1000);
}
void setColor(int red, int green, int blue) {
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
}
Does anyone know why this isn't working?