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
Fork of FTF2014_lab2_complete by
Diff: main.cpp
- Revision:
- 0:3561cbaefc3d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Apr 03 08:58:46 2014 +0000
@@ -0,0 +1,38 @@
+#include "mbed.h"
+
+DigitalOut led_red(LED_RED);
+InterruptIn sw2(SW2);
+Ticker ticker;
+float interval;
+
+void led_toggle(void)
+{
+ led_red = !led_red;
+}
+
+void sw2_release(void)
+{
+ printf("On-board button SW2 was released.\n");
+}
+
+void sw2_press(void)
+{
+ printf("On-board button SW2 was pressed.\n");
+ interval -= 0.1f;
+ ticker.detach();
+ ticker.attach(&led_toggle, interval);
+ printf("LED toogle interval was set to: %f \n", interval);
+ if (interval < 0.5f) {
+ interval = 1.1f;
+ }
+}
+
+int main()
+{
+ interval = 1.0f;
+ sw2.rise(&sw2_release);
+ sw2.fall(&sw2_press);
+ ticker.attach(&led_toggle, interval);
+ while (true) {
+ }
+}
