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.
Diff: main.cpp
- Revision:
- 0:cb4d2080abfb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Dec 13 13:49:57 2016 +0000
@@ -0,0 +1,31 @@
+#include "mbed.h"
+
+uint8_t LED_FREQ=5;
+
+void pressed(void);
+
+DigitalOut myled(LED1);
+InterruptIn event(USER_BUTTON);
+
+int main() {
+ printf("Flicker Fusion Threshold Test\n");
+ printf("Frequency: %uhz\n", LED_FREQ);
+
+ event.fall(&pressed); // Increase frequency when button is pressed.
+
+ while(1) {
+ myled = 1; // Turn ON the led
+ wait((float) 1 / LED_FREQ);
+ myled = 0; // Turn OFF the led
+ wait((float) 1 / LED_FREQ);
+ }
+}
+
+void pressed(void)
+{
+ // Increase frequency in 5hz steps; max = 100hz
+ LED_FREQ = (LED_FREQ >= 100 ? LED_FREQ = 5 : LED_FREQ+=5);
+
+ // Print to serial the new frequency
+ printf("Frequency: %uhz\n", LED_FREQ);
+}
\ No newline at end of file