The example program for mbed pin-compatible platforms
Fork of mbed_blinky by
Diff: main.cpp
- Revision:
- 1:8ec56da83b86
- Parent:
- 0:7dec7e9ac085
--- a/main.cpp Fri Oct 11 12:42:44 2013 +0000 +++ b/main.cpp Mon Nov 25 11:29:20 2013 +0000 @@ -1,12 +1,29 @@ #include "mbed.h" -DigitalOut myled(LED1); +DigitalOut myled(P0_21); // Define an output + +union BYTE // Define new type “BYTE” +{ + char Byte; // Use this to map a byte + struct { + char Bit0: 1; // map individual + char Bit1: 1; // bits onto the + char Bit2: 1; // mapped byte. + char Bit3: 1; + char Bit4: 1; + char Bit5: 1; + char Bit6: 1; + char Bit7: 1; + } Bits; +}; int main() { - while(1) { - myled = 1; - wait(0.2); - myled = 0; - wait(0.2); + BYTE cMyNumber; // Declare out counter + cMyNumber.Byte = 0; // Initialise our counter + + for(;;) { // Loop forever + wait(0.5); // Wait half a second + cMyNumber.Byte++; // Increment counter + myled = cMyNumber.Bits.Bit0; // Indicate odd value } }