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:
- 3:3cc8759a826f
- Parent:
- 2:51248529975d
--- a/main.cpp Tue Sep 11 15:24:39 2018 +0000
+++ b/main.cpp Wed Sep 12 10:16:23 2018 +0000
@@ -4,27 +4,27 @@
// 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
-
+//if character == ‘r’ blink red LED
+//if character == ‘b’ blink blue LED
+//if character == ‘g’ blink green LED
-Ticker blink; //Maak ticker aan
+Ticker blink; //Create the ticker
-//enum states {r,b,g}; //Define possible states
-char currentState; //Make variable currentState
+char currentState; //Make character currentState
-DigitalOut ledr(LED_RED);
+DigitalOut ledr(LED_RED); //Define DigitalOuts for every colour
DigitalOut ledb(LED_BLUE);
DigitalOut ledg(LED_GREEN);
-void BlinkLed(void)
+
+
+void BlinkLed(void) //Define the function which makes the led blink
{
- switch (currentState)
+ switch (currentState) //Make a switch which takes the character from the keyboard
{
- case 'r': //If the input character is r
- ledr = !ledr;
- ledb=1;
+ case 'r': //If the input character is r..
+ ledr = !ledr; //let the red light blink..
+ ledb=1; //and turn off the rest
ledg=1;
break;
@@ -41,13 +41,17 @@
break;
default:
- // pc.print("There is no input");
break;
} // End of switch
}
int main()
{
+//Start with the LED switched off
+ledr = 1;
+ledb = 1;
+ledg = 1;
+
blink.attach(BlinkLed,1); //Gaat elke seconde checken
pc.baud(115200); //Instelling voor pc