// // This program lights up one LED after another from P1.0 to P1.7, then P2.0 to P2.7, // and then it reverses. It looks like the light is bouncing from one side to the other. // unsigned long int lights; bool go_left = true; void setup() { P1DIR = 0b11111111; P2DIR = 0b11111111; lights = 1; } void loop() { if( lights & 1 ) go_left = true; else if( lights & (1<<15) ) go_left = false; if( go_left ) lights <<= 1; else lights >>= 1; P1OUT = lights; P2OUT = lights >> 8; delay( 50 ); }