serial communication test

Dependencies:   mbed

Committer:
mzpf46
Date:
Mon Oct 30 14:20:09 2017 +0000
Revision:
0:015c0b1cb2d4
serial communication test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mzpf46 0:015c0b1cb2d4 1 #include "mbed.h"
mzpf46 0:015c0b1cb2d4 2 #include "stdio.h"
mzpf46 0:015c0b1cb2d4 3 #include "math.h"
mzpf46 0:015c0b1cb2d4 4 /* Define some useful constants */
mzpf46 0:015c0b1cb2d4 5 #define HIGH 1
mzpf46 0:015c0b1cb2d4 6 #define LOW 0
mzpf46 0:015c0b1cb2d4 7 DigitalOut myled1(LED1); /* LED1 */
mzpf46 0:015c0b1cb2d4 8 Serial pc(USBTX, USBRX);
mzpf46 0:015c0b1cb2d4 9
mzpf46 0:015c0b1cb2d4 10
mzpf46 0:015c0b1cb2d4 11 int main() {
mzpf46 0:015c0b1cb2d4 12 char user_cmd;
mzpf46 0:015c0b1cb2d4 13 pc.scanf("%c",user_cmd);
mzpf46 0:015c0b1cb2d4 14
mzpf46 0:015c0b1cb2d4 15 int right='1';
mzpf46 0:015c0b1cb2d4 16
mzpf46 0:015c0b1cb2d4 17
mzpf46 0:015c0b1cb2d4 18 if(user_cmd==right)
mzpf46 0:015c0b1cb2d4 19 {
mzpf46 0:015c0b1cb2d4 20 myled1=HIGH;
mzpf46 0:015c0b1cb2d4 21 }
mzpf46 0:015c0b1cb2d4 22 }