test out

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /** 
00002     @file doc.h
00003 */
00004 #include "mbed.h"
00005 /** a blink class 
00006 *
00007 *   gettting the lay of the land
00008 */
00009 class BLINK{
00010     public:
00011     BLINK(PinName pin) : _pin(pin) {  // _pin(pin) means pass pin to the DigitalOut constructor
00012         _pin = LED2;                                        // default the output to LED2
00013     }
00014        /** let flash the led
00015         @pram n number of time to flash the led
00016        */
00017        void flash(int n) {
00018         for(int i=0; i<n*2; i++) {
00019             _pin = !_pin;
00020             wait(0.2);
00021         }
00022     }
00023 
00024 private:
00025     DigitalOut _pin;
00026 
00027 
00028 
00029 };
00030 
00031 
00032 DigitalOut myled(LED1);
00033 BLINK test(LED4);
00034 BLINK test2(LED3);
00035 int main() {
00036     int i=0;
00037     while(1) {
00038         myled = 1;
00039         wait(0.2);
00040         myled = 0;
00041         wait(0.2);
00042         test.flash(5);
00043         test2.flash(2);
00044          printf("Hello World![%i]\r\n",i++);
00045     }
00046 }