LEDs/Button example.
Dependencies: mbed
Revision 2:603a8ac68090, committed 2017-05-29
- Comitter:
- bcostm
- Date:
- Mon May 29 15:10:02 2017 +0200
- Parent:
- 1:d343cf676574
- Child:
- 3:50a3fc3bce95
- Commit message:
- Update main.cpp (typos) and mbed library to v143
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed May 17 09:17:45 2017 +0200
+++ b/main.cpp Mon May 29 15:10:02 2017 +0200
@@ -7,22 +7,25 @@
InterruptIn mybutton(USER_BUTTON);
-double tempo = 0.2; //time to wait
+double tempo = 0.2; // LED blinking delay
-void changetempo() {
- if(tempo == 0.2) // If leds have low frequency
- tempo = 0.1; // Set the fast frequency
- else // If les have fast frequency
- tempo = 0.2; // Set the low frequency
+// Change LEDs blinking frequency
+void change_blinking_frequency() {
+ if (tempo == 0.3) // If leds have low frequency
+ tempo = 0.1; // Set the fast frequency
+ else // If leds have fast frequency
+ tempo = 0.3; // Set the low frequency
}
int main() {
- myled1 = 0; //LED1 is OFF
- myled2 = 0; //LED2 is OFF
- myled3 = 0; //LED3 is OFF
- myled4 = 0; //LED4 is OFF
+ // All LEDs are OFF
+ myled1 = 0;
+ myled2 = 0;
+ myled3 = 0;
+ myled4 = 0;
- mybutton.fall(&changetempo); //Interrupt to change tempo
+ // Change LEDs blinking frequency when button is pressed
+ mybutton.fall(&change_blinking_frequency);
while(1) {
myled2 = 1; // LED2 is ON
--- a/mbed.bld Wed May 17 09:17:45 2017 +0200 +++ b/mbed.bld Mon May 29 15:10:02 2017 +0200 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/4eea097334d6 \ No newline at end of file +https://mbed.org/users/mbed_official/code/mbed/builds/86740a56073b \ No newline at end of file