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.
Revision 0:66b7dc06a323, committed 2016-09-16
- Comitter:
- megrootens
- Date:
- Fri Sep 16 15:26:34 2016 +0000
- Child:
- 1:847e4f0d71f5
- Commit message:
- Example solution Minor Biorobotics 2016; University of Twente,; Dept. of Biomechanical Engineering; Homework set 2, Exercise 1.
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MODSERIAL.lib Fri Sep 16 15:26:34 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/Sissors/code/MODSERIAL/#4737f8a5b018
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Sep 16 15:26:34 2016 +0000
@@ -0,0 +1,58 @@
+/**
+ * Minor BioRobotics 2016
+ *
+ * Programming Homework Set 2
+ * Exercise 1, example solution
+ *
+ * M.E. Grootens [at] utwente.nl,
+ * v0.1, 16.09.2016
+ */
+
+#include "mbed.h"
+#include "MODSERIAL.h"
+
+#define SERIAL_BAUD 115200 // baud rate for serial communication
+
+// Serial communication using MODSERIAL
+MODSERIAL pc(USBTX,USBRX);
+
+// LED that is to blink
+DigitalOut led_r(LED_RED);
+
+
+const float kTimeLedToggle = 0.5f; // period with which to toggle LED
+const int kLedOn = 0; // LED on if 0
+
+int num_turned_on = 0; // count number of times LED is turned on
+
+/**
+ * Toggle / Switch the state of the LED.
+ * Count the number of times the LED was turned ON.
+ */
+void ToggleLed()
+{
+ led_r = not led_r;
+ if (led_r == kLedOn) {
+ num_turned_on++;
+ pc.printf("LED has been turned on %d times\r\n",num_turned_on);
+ }
+}
+
+/**
+ * Main loop.
+ */
+int main()
+{
+ // Serial comm baud rate
+ pc.baud(SERIAL_BAUD);
+ pc.printf("\r\n**RESET**\r\n");
+
+ // Turn off LED initially
+ led_r = not kLedOn;
+
+ // Create ticker and attach LED toggle function
+ Ticker tick_toggle_led;
+ tick_toggle_led.attach(ToggleLed,kTimeLedToggle);
+
+ while (true);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Sep 16 15:26:34 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/2e9cc70d1897 \ No newline at end of file