// // This program makes a light appear to walk randomly around in a string // of 14 LEDs connected to P1.0 through P1.7 ans P2.0 through P2.5. // unsigned long int lights; bool go_left = true; void setup() { P1DIR = 0b11111111; P2DIR = 0b111111; lights = 1<<7; } void loop() { if( random( 100 ) > 50 ) go_left = true; else go_left = false; if( lights & 1 ) go_left = true; else if( lights & (1<<13) ) go_left = false; if( go_left ) lights <<= 1; else lights >>= 1; P1OUT = lights; P2OUT = lights >> 8; delay( 100 ); }