Gruppe_A
Dependencies: mbed
Fork of GruppeA by
Diff: GruppeA.cpp
- Revision:
- 0:74db8ce1771f
- Child:
- 1:bb1a9447ce78
diff -r 000000000000 -r 74db8ce1771f GruppeA.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GruppeA.cpp Wed Jun 10 16:22:46 2015 +0000 @@ -0,0 +1,126 @@ +#include "mbed.h" + + +InterruptIn iiUp(p15); +Timer timer1; +int los=0; +int b=0; +int text_neu = 0; + +BusOut doLeds(LED1,LED2,LED3,LED4); + +// global vars and objects +DigitalOut led2(LED2); +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() { + + //if(los>=1) + //{ + recChar = pc.getc(); + recArr[index] = recChar; + index++; + if ((recChar == '\r') || (index>=19)) { + recFlag = true; + recArr[index] = 0; + + float t = timer1.read_ms(); + pc.printf(" - That's the input: %f L= %d %s\r\n", t,index,recArr); + if(recArr[0] == 'A' || recArr[0] == 'a') + { + pc.printf("Aus"); + doLeds=0; + + + + } + if(recArr[0] == 'e' || recArr[0] == 'E') + { + pc.printf("ein"); + doLeds=15; + + + + } + + + if(recArr[0] == 'L') + { + + + + + + + } + + + + + + index = 0; + timer1.stop(); + timer1.reset(); + flushSerialBuffer(); + los=0; + + //} + } +} + + void SendText() + { + + pc.printf("Geben Sie ein Wort mit mindestens 5 und maximal 10 ein:"); + timer1.start(); + los=1; + + } + +int main() { + pc.baud(115200); + //pc.baud(38400); + pc.format(8, SerialBase::Odd, 2); + led2 = 1; + + flushSerialBuffer(); + if(b>=0) + { + pc.printf("Programm Andreas Schögler Gruppe2 \r\n"); + b=1; + } + + pc.attach(&readData); + + flushSerialBuffer(); + if(text_neu>=0) + { + pc.printf("Bitte Steuer_string eingeben \r\n"); + text_neu=1; + } + + + //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; + } + } +} \ No newline at end of file