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:b39846a16d3f, 2017-06-06 (annotated)
- Committer:
- arostm
- Date:
- Tue Jun 06 15:40:46 2017 +0200
- Revision:
- 1:b39846a16d3f
- Parent:
- 0:304d51e55354
Adding new mbed library
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| bcostm | 0:304d51e55354 | 1 | #include "mbed.h" |
| bcostm | 0:304d51e55354 | 2 | |
| bcostm | 0:304d51e55354 | 3 | DigitalOut led_green(LED1); |
| bcostm | 0:304d51e55354 | 4 | DigitalOut led_red(LED2); |
| bcostm | 0:304d51e55354 | 5 | |
| bcostm | 0:304d51e55354 | 6 | InterruptIn user_button(USER_BUTTON); |
| bcostm | 0:304d51e55354 | 7 | |
| bcostm | 0:304d51e55354 | 8 | float delay_on = 0.2; |
| bcostm | 0:304d51e55354 | 9 | float delay_off = 1.0; |
| bcostm | 0:304d51e55354 | 10 | |
| bcostm | 0:304d51e55354 | 11 | void button_pressed() |
| bcostm | 0:304d51e55354 | 12 | { |
| bcostm | 0:304d51e55354 | 13 | delay_on = 0.1; |
| bcostm | 0:304d51e55354 | 14 | delay_off = 0.1; |
| bcostm | 0:304d51e55354 | 15 | } |
| bcostm | 0:304d51e55354 | 16 | |
| bcostm | 0:304d51e55354 | 17 | void button_released() |
| bcostm | 0:304d51e55354 | 18 | { |
| bcostm | 0:304d51e55354 | 19 | delay_on = 0.2; |
| bcostm | 0:304d51e55354 | 20 | delay_off = 1.0; |
| bcostm | 0:304d51e55354 | 21 | } |
| bcostm | 0:304d51e55354 | 22 | |
| bcostm | 0:304d51e55354 | 23 | int main() |
| bcostm | 0:304d51e55354 | 24 | { |
| bcostm | 0:304d51e55354 | 25 | user_button.rise(&button_pressed); |
| bcostm | 0:304d51e55354 | 26 | user_button.fall(&button_released); |
| bcostm | 0:304d51e55354 | 27 | |
| bcostm | 0:304d51e55354 | 28 | while(1) { |
| bcostm | 0:304d51e55354 | 29 | // LEDs are ON |
| bcostm | 0:304d51e55354 | 30 | led_green = 1; |
| bcostm | 0:304d51e55354 | 31 | led_red = 1; |
| bcostm | 0:304d51e55354 | 32 | wait(delay_on); |
| bcostm | 0:304d51e55354 | 33 | // LEDs are OFF |
| bcostm | 0:304d51e55354 | 34 | led_green = 0; |
| bcostm | 0:304d51e55354 | 35 | led_red = 0; |
| bcostm | 0:304d51e55354 | 36 | wait(delay_off); |
| bcostm | 0:304d51e55354 | 37 | } |
| bcostm | 0:304d51e55354 | 38 | } |