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: mbed
main.cpp@1:eca2951a22e3, 2017-06-06 (annotated)
- Committer:
- arostm
- Date:
- Tue Jun 06 15:20:36 2017 +0200
- Revision:
- 1:eca2951a22e3
- Parent:
- 0:105640b9dc00
Adding new mbed library
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| bcostm | 0:105640b9dc00 | 1 | #include "mbed.h" |
| bcostm | 0:105640b9dc00 | 2 | |
| bcostm | 0:105640b9dc00 | 3 | DigitalOut red_led(LED1); |
| bcostm | 0:105640b9dc00 | 4 | DigitalOut blue_led(LED2); |
| bcostm | 0:105640b9dc00 | 5 | DigitalOut orange_led(LED3); |
| bcostm | 0:105640b9dc00 | 6 | DigitalOut green_led(LED4); |
| bcostm | 0:105640b9dc00 | 7 | |
| bcostm | 0:105640b9dc00 | 8 | InterruptIn user_button(USER_BUTTON); |
| bcostm | 0:105640b9dc00 | 9 | |
| bcostm | 0:105640b9dc00 | 10 | void button_pressed() |
| bcostm | 0:105640b9dc00 | 11 | { |
| bcostm | 0:105640b9dc00 | 12 | // LEDs ON |
| bcostm | 0:105640b9dc00 | 13 | green_led = 1; |
| bcostm | 0:105640b9dc00 | 14 | blue_led = 1; |
| bcostm | 0:105640b9dc00 | 15 | orange_led = 1; |
| bcostm | 0:105640b9dc00 | 16 | } |
| bcostm | 0:105640b9dc00 | 17 | |
| bcostm | 0:105640b9dc00 | 18 | void button_released() |
| bcostm | 0:105640b9dc00 | 19 | { |
| bcostm | 0:105640b9dc00 | 20 | // LEDs OFF |
| bcostm | 0:105640b9dc00 | 21 | green_led = 0; |
| bcostm | 0:105640b9dc00 | 22 | blue_led = 0; |
| bcostm | 0:105640b9dc00 | 23 | orange_led = 0; |
| bcostm | 0:105640b9dc00 | 24 | } |
| bcostm | 0:105640b9dc00 | 25 | |
| bcostm | 0:105640b9dc00 | 26 | int main() { |
| bcostm | 0:105640b9dc00 | 27 | |
| bcostm | 0:105640b9dc00 | 28 | user_button.rise(&button_pressed); |
| bcostm | 0:105640b9dc00 | 29 | user_button.fall(&button_released); |
| bcostm | 0:105640b9dc00 | 30 | |
| bcostm | 0:105640b9dc00 | 31 | while(1) { |
| bcostm | 0:105640b9dc00 | 32 | red_led = !red_led; // LED toggle |
| bcostm | 0:105640b9dc00 | 33 | wait(0.2); |
| bcostm | 0:105640b9dc00 | 34 | } |
| bcostm | 0:105640b9dc00 | 35 | |
| bcostm | 0:105640b9dc00 | 36 | } |