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.
main.cpp
- Committer:
- Mirjam
- Date:
- 2018-09-11
- Revision:
- 0:9ac802a0d2d9
- Child:
- 1:b483225a5411
File content as of revision 0:9ac802a0d2d9:
#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();
}
}