Knapp trykket skriver L på rising, O på falling. Skrur LED av med L, på med O
Dependencies: mbed
Fork of LAB10_Oppgave3 by
Revision 2:05c503638488, committed 2015-11-05
- Comitter:
- Voldread
- Date:
- Thu Nov 05 16:14:53 2015 +0000
- Parent:
- 1:05b1d2a203e5
- Commit message:
- s
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 05b1d2a203e5 -r 05c503638488 main.cpp --- a/main.cpp Wed Nov 04 21:02:48 2015 +0000 +++ b/main.cpp Thu Nov 05 16:14:53 2015 +0000 @@ -2,19 +2,44 @@ Serial serial3(PB_9, PB_8); // tx, rx Serial pc(USBTX, USBRX); // tx, rx +InterruptIn knapp(PC_13); +DigitalOut userLed(PA_5); void serial3Rx() -{ pc.putc(serial3.getc()); +{ + char rxData=serial3.getc(); + if (rxData=='L') { + userLed=1; + } + + if (rxData=='O') { + userLed=0; + } + + pc.putc(rxData); } void pcRx() -{ serial3.putc(pc.getc()); +{ + serial3.putc(pc.getc()); +} + +void KnappTrykket() +{ + serial3.putc('L'); +} + +void KnappTrykketO() +{ + serial3.putc('O'); } int main() { serial3.attach(&serial3Rx); pc.attach(&pcRx); + knapp.fall(&KnappTrykket); + knapp.rise(&KnappTrykketO); while(1) { wait(1);