// This example lights up 8 leds in sequence. The leds // are connected to digital i/o pins 0-7. int p = 0; // holds which led is on void setup() { for (int i=0; i<8; i++) { // set digital pins 0-7 as outputs pinMode(i, OUTPUT); } } void loop() { p++; // advance p to next pin p = (p+8) % 8; // limit p between 0-7 for (int i=0; i<8; i++) { if (i == p) { // set pin p HIGH digitalWrite(i, HIGH); } else { digitalWrite(i, LOW); // and all other pins LOW } } delay(200); // wait 200 millisecs }