Simple binary upcounter

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 // 4 bit binary counter, using onboard LEDs
00002 #include "mbed.h"
00003 
00004 unsigned char i;                                        // Make variable "i" a char (8bit)
00005 
00006 BusOut leds(LED4, LED3, LED2, LED1);                    // Create a BusOut variable "leds", with LED1-4
00007 
00008 int main() {                                            // Main structure
00009     while(1) {                                          // While-loop (Do forever)
00010         leds = leds+1;                                  // Every loop, add one to leds variable
00011         wait(0.5);                                      // Wait for .5 seconds
00012     }                                                   // End of While-loop
00013 }                                                       // End of Main structure