Process Data from Serial port and give keyboard shortcut

Dependencies:   mbed

Committer:
RohanIyengar
Date:
Mon Dec 12 10:47:50 2016 +0000
Revision:
0:7fe62cc94779
publish commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RohanIyengar 0:7fe62cc94779 1 #include "mbed.h"
RohanIyengar 0:7fe62cc94779 2
RohanIyengar 0:7fe62cc94779 3 Serial pc(USBTX, USBRX);
RohanIyengar 0:7fe62cc94779 4 DigitalOut myled(LED1);
RohanIyengar 0:7fe62cc94779 5
RohanIyengar 0:7fe62cc94779 6 char buffer[20];
RohanIyengar 0:7fe62cc94779 7 char hi;
RohanIyengar 0:7fe62cc94779 8 volatile char curr[20];
RohanIyengar 0:7fe62cc94779 9
RohanIyengar 0:7fe62cc94779 10 int main() {
RohanIyengar 0:7fe62cc94779 11 myled = 1;
RohanIyengar 0:7fe62cc94779 12 while(1) {
RohanIyengar 0:7fe62cc94779 13 wait(.01);
RohanIyengar 0:7fe62cc94779 14 if (pc.readable()) {
RohanIyengar 0:7fe62cc94779 15 pc.scanf("%s", buffer);
RohanIyengar 0:7fe62cc94779 16 //hi = (char) pc.getc();
RohanIyengar 0:7fe62cc94779 17 //curr = buffer;
RohanIyengar 0:7fe62cc94779 18 pc.printf(buffer);
RohanIyengar 0:7fe62cc94779 19 myled = 1;
RohanIyengar 0:7fe62cc94779 20 } else {
RohanIyengar 0:7fe62cc94779 21 //pc.printf(curr + "\n");
RohanIyengar 0:7fe62cc94779 22 myled = 0;
RohanIyengar 0:7fe62cc94779 23 }
RohanIyengar 0:7fe62cc94779 24 //pc.printf(curr);
RohanIyengar 0:7fe62cc94779 25 }
RohanIyengar 0:7fe62cc94779 26 }