cylon style LED display

Dependencies:   mbed

Committer:
4180_1
Date:
Thu Jan 31 19:30:17 2013 +0000
Revision:
1:e28b08062150
Parent:
0:a2a1c2f48b76
ver 1.2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
4180_1 0:a2a1c2f48b76 1 #include "mbed.h"
4180_1 0:a2a1c2f48b76 2 // Cylon style LED scanner
4180_1 0:a2a1c2f48b76 3 BusOut led_state(LED1, LED2, LED3, LED4);
4180_1 0:a2a1c2f48b76 4
4180_1 0:a2a1c2f48b76 5 int main() {
4180_1 0:a2a1c2f48b76 6 int i = 0;
4180_1 1:e28b08062150 7 // initial LED state
4180_1 0:a2a1c2f48b76 8 led_state = 0x1;
4180_1 0:a2a1c2f48b76 9 while (1) {
4180_1 0:a2a1c2f48b76 10 // loop through all states
4180_1 0:a2a1c2f48b76 11 for (i=0; i<6; i++) {
4180_1 0:a2a1c2f48b76 12 if (i<3)
4180_1 0:a2a1c2f48b76 13 // shift left 1 bit until high LED set
4180_1 0:a2a1c2f48b76 14 led_state = led_state << 1;
4180_1 0:a2a1c2f48b76 15 else
4180_1 0:a2a1c2f48b76 16 // then reverse and shift back to right 1 bit
4180_1 0:a2a1c2f48b76 17 led_state = led_state >> 1;
4180_1 0:a2a1c2f48b76 18 // time delay .1s to slow down display
4180_1 0:a2a1c2f48b76 19 wait(0.1);
4180_1 0:a2a1c2f48b76 20 }
4180_1 0:a2a1c2f48b76 21 }
4180_1 0:a2a1c2f48b76 22 }