cylon style LED display

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 // Cylon style LED scanner
00003 BusOut led_state(LED1, LED2, LED3, LED4);
00004 
00005 int main() {
00006     int i = 0;
00007     // initial LED state
00008     led_state = 0x1;
00009     while (1) {
00010         // loop through all states
00011         for (i=0; i<6; i++) {
00012             if (i<3)
00013                 // shift left 1 bit until high LED set
00014                 led_state = led_state << 1;
00015             else
00016                 // then reverse and shift back to right 1 bit
00017                 led_state = led_state >> 1;
00018             // time delay .1s to slow down display
00019             wait(0.1);
00020         }
00021     }
00022 }