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
00001 #include "mbed.h" 00002 #include "MODSERIAL.h" 00003 MODSERIAL pc(USBTX, USBRX);\ 00004 00005 // Make a BlinkLEd function using Ticker 00006 //Wait for a character to arrive pc.getc() in the main loop, 00007 //if character == ‘r’ blink red LED 00008 //if character == ‘b’ blink blue LED 00009 //if character == ‘g’ blink green LED 00010 00011 Ticker blink; //Create the ticker 00012 00013 char currentState; //Make character currentState 00014 00015 DigitalOut ledr(LED_RED); //Define DigitalOuts for every colour 00016 DigitalOut ledb(LED_BLUE); 00017 DigitalOut ledg(LED_GREEN); 00018 00019 00020 00021 void BlinkLed(void) //Define the function which makes the led blink 00022 { 00023 switch (currentState) //Make a switch which takes the character from the keyboard 00024 { 00025 case 'r': //If the input character is r.. 00026 ledr = !ledr; //let the red light blink.. 00027 ledb=1; //and turn off the rest 00028 ledg=1; 00029 break; 00030 00031 case 'b': //If the input character is b 00032 ledb = !ledb; 00033 ledr=1; 00034 ledg=1; 00035 break; 00036 00037 case 'g': //If the input character is g 00038 ledg= !ledg; 00039 ledb=1; 00040 ledr=1; 00041 break; 00042 00043 default: 00044 break; 00045 } // End of switch 00046 } 00047 00048 int main() 00049 { 00050 //Start with the LED switched off 00051 ledr = 1; 00052 ledb = 1; 00053 ledg = 1; 00054 00055 blink.attach(BlinkLed,1); //Gaat elke seconde checken 00056 pc.baud(115200); //Instelling voor pc 00057 00058 while (true) { 00059 currentState = pc.getc(); 00060 } 00061 }
Generated on Sun Jul 24 2022 08:54:20 by
1.7.2