A collection of examples organized from basics to advanced.
Dependencies: mbed SDFileSystem
Mbed online compiler has no facility to easily manage a lot of programs or organized them in to related folders. This makes creating an examples and sample pack difficult.
This repository contains a single main.cpp file (which does very little), and a BuildOptions.h file. Simply uncomment the example you would like to compile from the build options. Each example is wrapped in a compiler directive.
If the directive does not include a description comment, it likely does not exist yet. If you would like to contribute to the Examples project, please contact me or fork and issue a pull request.
02_Digital/Button_Interrupt.cpp@1:9a043ee174de, 2019-07-05 (annotated)
- Committer:
- epremeaux
- Date:
- Fri Jul 05 04:52:18 2019 +0000
- Revision:
- 1:9a043ee174de
- Parent:
- 01_Basics/Button_Interrupt.cpp@0:b471f7764d46
cleaning up and organizing directories. added a few programs
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
epremeaux | 0:b471f7764d46 | 1 | |
epremeaux | 0:b471f7764d46 | 2 | #ifdef COMPILE_Button_Interrupt |
epremeaux | 0:b471f7764d46 | 3 | |
epremeaux | 0:b471f7764d46 | 4 | |
epremeaux | 0:b471f7764d46 | 5 | InterruptIn button(USER_BUTTON); |
epremeaux | 0:b471f7764d46 | 6 | |
epremeaux | 0:b471f7764d46 | 7 | DigitalOut led(LED1); |
epremeaux | 0:b471f7764d46 | 8 | |
epremeaux | 0:b471f7764d46 | 9 | double delay = 0.5; // 500 ms |
epremeaux | 0:b471f7764d46 | 10 | |
epremeaux | 0:b471f7764d46 | 11 | void pressed() |
epremeaux | 0:b471f7764d46 | 12 | { |
epremeaux | 0:b471f7764d46 | 13 | delay = 0.1; // 100 ms |
epremeaux | 0:b471f7764d46 | 14 | } |
epremeaux | 0:b471f7764d46 | 15 | |
epremeaux | 0:b471f7764d46 | 16 | void released() |
epremeaux | 0:b471f7764d46 | 17 | { |
epremeaux | 0:b471f7764d46 | 18 | delay = 0.5; // 500 ms |
epremeaux | 0:b471f7764d46 | 19 | } |
epremeaux | 0:b471f7764d46 | 20 | |
epremeaux | 0:b471f7764d46 | 21 | int main() |
epremeaux | 0:b471f7764d46 | 22 | { |
epremeaux | 0:b471f7764d46 | 23 | // Assign functions to button |
epremeaux | 0:b471f7764d46 | 24 | button.fall(&pressed); |
epremeaux | 0:b471f7764d46 | 25 | button.rise(&released); |
epremeaux | 0:b471f7764d46 | 26 | |
epremeaux | 0:b471f7764d46 | 27 | while (1) { |
epremeaux | 0:b471f7764d46 | 28 | led = !led; |
epremeaux | 0:b471f7764d46 | 29 | wait(delay); |
epremeaux | 0:b471f7764d46 | 30 | } |
epremeaux | 0:b471f7764d46 | 31 | } |
epremeaux | 0:b471f7764d46 | 32 | |
epremeaux | 0:b471f7764d46 | 33 | #endif |