// // This program controls the brightness of 16 LEDs on a scale from 0 to 15. // As the pattern moves right to left (or clockwise if the LEDs are arranged // in a circle, the brightest LED is at the front, and subsequent LEDs are // each one step dimmer, like the tail of a comet. // unsigned char values[16] = { 0, 1, 3, 6, 10, 15, 21, 27, 34, 41, 50, 58, 68, 78, 88, 99 }; unsigned int index = 0; unsigned int shift = 0; int cnt = 0; void setup() { P1DIR = 0b11111111; P2DIR = 0b11111111; P1OUT = 0; P2OUT = 0; } void loop() { for( int x = 0; x < 200; x++ ) { int lights = 0; for( char y = 0; y < 16; y++ ) { if( x < values[(y+shift)&0b1111] ) { lights |= 1 << y; } } P1OUT = lights; P2OUT = lights >> 8; } if( cnt++ > 10 ) { shift--; cnt = 0; } }