Modified hello world - usb debug message only
Fork of mDot_helloworld by
main.cpp@1:34c1fcb8ea5a, 2015-07-07 (annotated)
- Committer:
- mfiore
- Date:
- Tue Jul 07 14:09:33 2015 +0000
- Revision:
- 1:34c1fcb8ea5a
- Parent:
- 0:fdc94d24e54a
- Child:
- 2:9682d754c902
add #define for easy switching between UDK2.0 and Micro UDK
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mfiore | 0:fdc94d24e54a | 1 | /************************************* |
mfiore | 0:fdc94d24e54a | 2 | * This simple example program blinks |
mfiore | 1:34c1fcb8ea5a | 3 | * a LED and prints a message out the |
mfiore | 0:fdc94d24e54a | 4 | * USB debug port. |
mfiore | 0:fdc94d24e54a | 5 | ************************************/ |
mfiore | 0:fdc94d24e54a | 6 | |
mfiore | 0:fdc94d24e54a | 7 | #include "mbed.h" |
mfiore | 0:fdc94d24e54a | 8 | |
mfiore | 1:34c1fcb8ea5a | 9 | // Uncomment this line if using a full sized UDK2.0 instead of a Micro UDK |
mfiore | 1:34c1fcb8ea5a | 10 | // #define UDK2 1 |
mfiore | 1:34c1fcb8ea5a | 11 | |
mfiore | 1:34c1fcb8ea5a | 12 | #ifdef UDK2 |
mfiore | 0:fdc94d24e54a | 13 | DigitalOut led(LED1); |
mfiore | 1:34c1fcb8ea5a | 14 | #else |
mfiore | 1:34c1fcb8ea5a | 15 | DigitalOut led(XBEE_RSSI); |
mfiore | 1:34c1fcb8ea5a | 16 | #endif |
mfiore | 1:34c1fcb8ea5a | 17 | |
mfiore | 0:fdc94d24e54a | 18 | Ticker tick; |
mfiore | 0:fdc94d24e54a | 19 | |
mfiore | 0:fdc94d24e54a | 20 | // callback function to change LED state |
mfiore | 0:fdc94d24e54a | 21 | void blink() { |
mfiore | 0:fdc94d24e54a | 22 | led = !led; |
mfiore | 0:fdc94d24e54a | 23 | } |
mfiore | 0:fdc94d24e54a | 24 | |
mfiore | 0:fdc94d24e54a | 25 | int main() { |
mfiore | 0:fdc94d24e54a | 26 | // configure the Ticker to blink the LED on 500ms interval |
mfiore | 0:fdc94d24e54a | 27 | tick.attach(&blink, 0.5); |
mfiore | 0:fdc94d24e54a | 28 | |
mfiore | 0:fdc94d24e54a | 29 | // print the message on 2s interval |
mfiore | 0:fdc94d24e54a | 30 | while (true) { |
mfiore | 0:fdc94d24e54a | 31 | printf("Hello world!\r\n"); |
mfiore | 0:fdc94d24e54a | 32 | wait(2); |
mfiore | 0:fdc94d24e54a | 33 | } |
mfiore | 0:fdc94d24e54a | 34 | } |