![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
a,b Gruppe B
Dependencies: mbed
Gruppe_B_MatthiasPlaninsec.cpp
- Committer:
- Planinsec
- Date:
- 2015-06-10
- Revision:
- 0:8a6f8b1df4ea
File content as of revision 0:8a6f8b1df4ea:
#include "mbed.h" InterruptIn iiUp(p15); //Timer timer1; int los=0; // global vars and objects DigitalOut led2(LED2); //DigitalOut ledAlle(LED1,LED2, LED3,LED4); Serial pc(USBTX, USBRX); // tx, rx ; is default !!! (9600, 8N1) char recChar=0; bool recFlag=false; char recArr[20]; int index=0; // functions void flushSerialBuffer() { while (pc.readable()) { pc.getc(); } } void readData() { //recArr[index] = recChar; if ( pc.readable()) //recChar == '\r') || (index>=19) { recChar = pc.getc(); //recFlag = true; //recArr[index] = 0; // float t = timer1.read_ms(); pc.printf(" - That's the input: \n",recArr); //if(index<5) //{ // pc.printf("Eingabe zu kurz "); //} //if(index>10) //{ // pc.printf("Eingabe zu lang "); //} //index = 0; flushSerialBuffer(); //los=0; } else { return; } } void SendText() { pc.printf("Folgende Befehle werden ausgefuehrt:"); pc.printf("r oder R = alle LEDs aus\n"); pc.printf("s oder S = alle LEDs ein\n"); pc.printf("s,Lx = LED x ein (X=1...4\n"); pc.printf("r,Lx = LED x aus (X=1...4\n"); pc.printf("I=alle LEDs invertieren (leuchtende LEDs aus, dunkle LEDs ein)\n"); //timer1.start(); los=1; } int main() { // pc.baud(115200); pc.baud(38400); pc.format(8, SerialBase::Odd, 2); led2 = 1; flushSerialBuffer(); pc.printf("Matthias Planinsec Gruppe B\r\n"); pc.attach(&readData); SendText(); //iiUp.rise(&SendText); while(1) { if (recFlag) { flushSerialBuffer(); // pc.printf(" - That's the input: %s\r\n", recArr); // non reantrant function recFlag = false; led2 = !led2; } } }