// // This program moves five lights from left to right, in such a way that if the // LEDs are arranged in a circle, it looks like the train is moving around it clockwise. // The 16 LEDs are connected to P1.0 through P1.7 and P2.0 through P2.7. // unsigned long int train = 0b11111; int train_length = 5; int how_many_p1_lights = 8; int how_many_p2_lights = 8; int total_lights = 8 + 8; int x = 0; void setup() { P1DIR = 0b11111111; P2DIR = 0b11111111; } void loop() { train <<= 1; train = train | (train >> total_lights); P1OUT = train >> train_length; P2OUT = train >> (train_length + how_many_p1_lights); delay( 50 ); }