/* Simple Cylon / knight rider kitt
Cylon Eye sweep using 8 LEDs
http://www.hobbytronics.co.uk/arduino-tutorial4-cylon
*/
unsigned char upDown=1; // start off going UP
unsigned char cylon=0; // determines which LED is on 0 to 7
void setup() {
// initialize the digital pins as outputs.
DDRD = B11111111; // sets Arduino port D pins 0 to 7 as outputs
}
void loop() {
if(upDown==1){
cylon++;
if(cylon>=7) upDown=0; // Reached max LED, next time we need to go down
}
else {
cylon--;
if(cylon==0) upDown=1; // Reached min LED, next time we need to go up
}
PORTD = 1 << cylon;
delay(100); // wait for 0.1 second
}