02-01 SimpleLED
From Manuals
(Difference between revisions)
(Created page with 'A very simple example that blinks the User LEDs. The User LEDs blink once per second in an alternating pattern. It shows a basic way to enable the GPIO pins. [[Image:BAM210_Blin…') |
|||
| (10 intermediate revisions not shown) | |||
| Line 1: | Line 1: | ||
| - | A very simple example that blinks | + | A very simple example that blinks LED1. LED1 blinks around 2 times a second. LED1 is located in the bottom left hand corner of the board. |
| + | |||
| + | The LEDs for the MBED-SDK and the Bambino line of microcontrollers are mapped to the following LEDs: | ||
| + | {| border="1" cellpadding="5" cellspacing="2" align="center" style="text-align: center;" | ||
| + | |+ align="bottom"|'''LED Colors''' | ||
| + | |'''LED''' | ||
| + | |'''PIN NAME''' | ||
| + | |'''BAM210E''' | ||
| + | |'''BAM210''' | ||
| + | |'''BAM200E''' | ||
| + | |'''BAM200''' | ||
| + | |- | ||
| + | |LED1 | ||
| + | |P6_11 | ||
| + | |Yellow LED | ||
| + | |Yellow LED | ||
| + | |Yellow LED | ||
| + | |Yellow LED | ||
| + | |- | ||
| + | |LED2 | ||
| + | |P2_5 | ||
| + | |Green LED | ||
| + | |Green LED | ||
| + | |Green LED | ||
| + | |Green LED | ||
| + | |- | ||
| + | |LED3 | ||
| + | |P6_1 | ||
| + | |RED LED | ||
| + | |RED LED | ||
| + | |n/p | ||
| + | |n/p | ||
| + | |- | ||
| + | |LED4 | ||
| + | |P6_2 | ||
| + | |Blue LED | ||
| + | |Blue LED | ||
| + | |n/p | ||
| + | |n/p | ||
| + | |- | ||
| + | |} | ||
| + | |||
| + | /* Program Example 2.1: Simple LED flashing | ||
| + | */ | ||
| + | #include "mbed.h" | ||
| + | DigitalOut myled(LED1); | ||
| + | |||
| + | int main() | ||
| + | { | ||
| + | while(1) { | ||
| + | myled = 1; | ||
| + | wait(0.2); | ||
| + | myled = 0; | ||
| + | wait(0.2); | ||
| + | } | ||
| + | } | ||
[[Image:BAM210_Blinky.jpeg|center|]] | [[Image:BAM210_Blinky.jpeg|center|]] | ||
Current revision as of 17:30, 17 September 2014
A very simple example that blinks LED1. LED1 blinks around 2 times a second. LED1 is located in the bottom left hand corner of the board.
The LEDs for the MBED-SDK and the Bambino line of microcontrollers are mapped to the following LEDs:
| LED | PIN NAME | BAM210E | BAM210 | BAM200E | BAM200 |
| LED1 | P6_11 | Yellow LED | Yellow LED | Yellow LED | Yellow LED |
| LED2 | P2_5 | Green LED | Green LED | Green LED | Green LED |
| LED3 | P6_1 | RED LED | RED LED | n/p | n/p |
| LED4 | P6_2 | Blue LED | Blue LED | n/p | n/p |
/* Program Example 2.1: Simple LED flashing
*/
#include "mbed.h"
DigitalOut myled(LED1);
int main()
{
while(1) {
myled = 1;
wait(0.2);
myled = 0;
wait(0.2);
}
}

