This simply counts from 0-15 continuously, displaying the binary value using the LED\'s along the bottom of the mbed.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 DigitalOut l1(LED1);
00004 DigitalOut l2(LED2);
00005 DigitalOut l3(LED3);
00006 DigitalOut l4(LED4);
00007 
00008 #define D() wait(0.5)
00009 
00010 int main() {
00011 
00012     int count = 0;
00013     while (1)
00014     {
00015         if (count & 0x08) l1 = 1;
00016         if (count & 0x04) l2 = 1;
00017         if (count & 0x02) l3 = 1;
00018         if (count & 0x01) l4 = 1;
00019         
00020         D();
00021         l1=l2=l3=l4=0;
00022         if (count==15) count = 0;
00023         else count++;
00024     }
00025 
00026 }