Arduino - RGB Light

Rotating colors using the RGB bulb.

Variables

int pins[3] = {10,9,6};

setup()

void setup(){
  Serial.begin(9600);
  for(int ctr = 0; ctr < 3; ctr++){
    pinMode(pins[ctr],OUTPUT);
    Serial.println(pins[ctr]);
  }
}

loop()

void loop(){
    rgb(255,255,255);
    rgb(255,000,000);
    rgb(255,255,000);
    rgb(000,255,000);
    rgb(000,255,255);
    rgb(000,000,255);
    rgb(255,000,255);
}

rgb()

Using my own custom function, I pass the red, green and blue values.

void rgb(int r, int g, int b){
    analogWrite(pins[0],r);
    analogWrite(pins[1],g);
    analogWrite(pins[2],b);
    delay(1000);
}

Demo Video