Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FRDM_MMA8451Q MAG3110 TSI mbed
main.cpp@1:28c81db67f50, 2013-12-18 (annotated)
- Committer:
- mmaas
- Date:
- Wed Dec 18 21:17:13 2013 +0000
- Revision:
- 1:28c81db67f50
- Parent:
- 0:79ae6809c2d0
- Child:
- 2:48ac01f5024d
Confirmed support for two on-board LEDs. Confirmed references and included defines for values corresponding to ON and OFF states.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| mmaas | 0:79ae6809c2d0 | 1 | #include "mbed.h" |
| mmaas | 0:79ae6809c2d0 | 2 | |
| mmaas | 1:28c81db67f50 | 3 | // Include support for USB Serial console |
| mmaas | 0:79ae6809c2d0 | 4 | Serial pc(USBTX, USBRX); |
| mmaas | 0:79ae6809c2d0 | 5 | |
| mmaas | 1:28c81db67f50 | 6 | // Include support for on-board green and red LEDs |
| mmaas | 1:28c81db67f50 | 7 | DigitalOut grnLED(LED_GREEN); |
| mmaas | 1:28c81db67f50 | 8 | DigitalOut redLED(LED_RED); |
| mmaas | 1:28c81db67f50 | 9 | |
| mmaas | 1:28c81db67f50 | 10 | // Definitions for LED states (logic inverted output value 0 = O) |
| mmaas | 1:28c81db67f50 | 11 | #define LED_ON 0 |
| mmaas | 1:28c81db67f50 | 12 | #define LED_OFF 1 |
| mmaas | 0:79ae6809c2d0 | 13 | |
| mmaas | 0:79ae6809c2d0 | 14 | int main() { |
| mmaas | 0:79ae6809c2d0 | 15 | |
| mmaas | 1:28c81db67f50 | 16 | // Ensure LEDs are off |
| mmaas | 1:28c81db67f50 | 17 | grnLED = LED_OFF; |
| mmaas | 1:28c81db67f50 | 18 | redLED = LED_OFF; |
| mmaas | 1:28c81db67f50 | 19 | |
| mmaas | 0:79ae6809c2d0 | 20 | // Set Serial Port data rate and say Hello |
| mmaas | 0:79ae6809c2d0 | 21 | pc.baud( 230400 ); |
| mmaas | 0:79ae6809c2d0 | 22 | pc.printf("Hello World\r\n"); |
| mmaas | 0:79ae6809c2d0 | 23 | |
| mmaas | 1:28c81db67f50 | 24 | // Blink LEDs - green first |
| mmaas | 0:79ae6809c2d0 | 25 | while(1) { |
| mmaas | 1:28c81db67f50 | 26 | grnLED = LED_ON; |
| mmaas | 1:28c81db67f50 | 27 | redLED = LED_OFF; |
| mmaas | 1:28c81db67f50 | 28 | |
| mmaas | 1:28c81db67f50 | 29 | wait(1); |
| mmaas | 1:28c81db67f50 | 30 | |
| mmaas | 1:28c81db67f50 | 31 | grnLED = LED_OFF; |
| mmaas | 1:28c81db67f50 | 32 | redLED = LED_ON; |
| mmaas | 1:28c81db67f50 | 33 | |
| mmaas | 1:28c81db67f50 | 34 | wait(1); |
| mmaas | 1:28c81db67f50 | 35 | |
| mmaas | 0:79ae6809c2d0 | 36 | } |
| mmaas | 0:79ae6809c2d0 | 37 | } |
