Wednesday, February 22, 2012

Flashing Leds solution

After posting on Lets make Robots looking for some info on getting the  code to work ..... I got a reply with this code which dose the job .....



int del=1000;
 void setup()
 {
for (int i =2; i<10;i++)
{
 pinMode(i,OUTPUT);
 }
 }
void loop()
{
 for (int i=2; i<=5; i++)
 {
 lightUp(i,11-i);
 }
for(int i=5; i>=2; i--)
 {
 lightUp(i, 11- i);
 }
}
 void lightUp(uint8_tpin1,uint8_tpin2)
{
digitalWrite(pin1, HIGH);
digitalWrite(pin2, HIGH);
delay(del);
digitalWrite(pin1, LOW);
digitalWrite(pin2, LOW);
}

No comments:

Post a Comment