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:
- 2:51248529975d
- Parent:
- 1:b483225a5411
- Child:
- 3:3cc8759a826f
File content as of revision 2:51248529975d:
#include "mbed.h"
#include "MODSERIAL.h"
MODSERIAL pc(USBTX, USBRX);\
// 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
char 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;
ledb=1;
ledg=1;
break;
case 'b': //If the input character is b
ledb = !ledb;
ledr=1;
ledg=1;
break;
case 'g': //If the input character is g
ledg= !ledg;
ledb=1;
ledr=1;
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
while (true) {
currentState = pc.getc();
}
}