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:9ac802a0d2d9
- Child:
- 1:b483225a5411
diff -r 000000000000 -r 9ac802a0d2d9 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Sep 11 15:02:25 2018 +0000
@@ -0,0 +1,52 @@
+#include "mbed.h"
+#include "MODSERIAL.h"
+// Make a BlinkLEd function using Ticker
+//Wait for a character to arrive pc.getc() in the main loop,
+//if character == ‘r’ blink red LED
+//if character == ‘b’ blink blue LED
+//if character == ‘g’ blink green LED
+
+Ticker blink; //Maak ticker aan
+
+enum states {r,b,g}; //Define possible states
+states currentState; //Make variable currentState
+
+DigitalOut ledr(LED_RED);
+DigitalOut ledb(LED_BLUE);
+DigitalOut ledg(LED_GREEN);
+
+void BlinkLed(void)
+{
+ switch (currentState)
+ {
+ case r: //If the input character is r
+ ledr = !ledr;
+ break;
+
+ case b: //If the input character is b
+ ledb = !ledb;
+ break;
+
+ case g: //If the input character is g
+ ledg= !ledg;
+ break;
+
+ default:
+ // pc.print("There is no input");
+ break;
+ } // End of switch
+
+
+int main()
+{
+ blink.attach(BlinkLed,1); //Gaat elke seconde checken
+ pc.baud(115200); //Instelling voor pc
+
+ char c; // Maak character c aan
+ c = pc.getc(); // Maak die gelijk aan ingevoerde character
+
+ while (true) {
+ currentState = c;
+ BlinkLed();
+ }
+}
\ No newline at end of file