Friday, January 18, 2013

Rainbow LED Blinker




Pictures:





Code:

int ledR = 0;
int ledO = 1;
int ledY = 2;
int ledG = 3;
int ledB = 4;
int ledW = 5;
int timeBlink=200;

// the setup routine runs once when you press reset:
void setup() {              
  // initialize the digital pin as an output.
  pinMode(ledR, OUTPUT);
  pinMode(ledO, OUTPUT);
  pinMode(ledY, OUTPUT);
  pinMode(ledG, OUTPUT);
  pinMode(ledB, OUTPUT);
  pinMode(ledW, OUTPUT);  
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(ledR, HIGH);
  delay(timeBlink);
  digitalWrite(ledO, HIGH);
  delay(timeBlink);
  digitalWrite(ledY, HIGH);
  delay(timeBlink);
    digitalWrite(ledG, HIGH);
  delay(timeBlink);
    digitalWrite(ledB, HIGH);
  delay(timeBlink);
    digitalWrite(ledW, HIGH);
  delay(timeBlink);
  digitalWrite(ledR, LOW);
  delay(timeBlink);            
  digitalWrite(ledO, LOW);
  delay(timeBlink);    
    digitalWrite(ledY, LOW);
  delay(timeBlink);    
    digitalWrite(ledG, LOW);
  delay(timeBlink);    
    digitalWrite(ledB, LOW);
  delay(timeBlink);    
    digitalWrite(ledW, LOW);
  delay(timeBlink);    
}

No comments:

Post a Comment