complete motor

Dependencies:   BufferedSerial motor_sn7544

Committer:
kangmingyo
Date:
Thu May 09 11:27:32 2019 +0000
Revision:
0:dde6e4d8c301
Child:
1:1d18a2e8ce45
aa

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kangmingyo 0:dde6e4d8c301 1 #include "mbed.h"
kangmingyo 0:dde6e4d8c301 2
kangmingyo 0:dde6e4d8c301 3 Serial pc(USBTX,USBRX,115200);
kangmingyo 0:dde6e4d8c301 4 DigitalOut led(LED2);
kangmingyo 0:dde6e4d8c301 5
kangmingyo 0:dde6e4d8c301 6 void rx_cn(void){
kangmingyo 0:dde6e4d8c301 7
kangmingyo 0:dde6e4d8c301 8 while(true){
kangmingyo 0:dde6e4d8c301 9 char ch;
kangmingyo 0:dde6e4d8c301 10 ch =pc.getc();
kangmingyo 0:dde6e4d8c301 11 pc.putc(ch);
kangmingyo 0:dde6e4d8c301 12
kangmingyo 0:dde6e4d8c301 13 if(ch ==0x0D){
kangmingyo 0:dde6e4d8c301 14 pc.putc(0x0A);
kangmingyo 0:dde6e4d8c301 15 }
kangmingyo 0:dde6e4d8c301 16
kangmingyo 0:dde6e4d8c301 17 }
kangmingyo 0:dde6e4d8c301 18
kangmingyo 0:dde6e4d8c301 19 }
kangmingyo 0:dde6e4d8c301 20
kangmingyo 0:dde6e4d8c301 21
kangmingyo 0:dde6e4d8c301 22
kangmingyo 0:dde6e4d8c301 23 int main(){
kangmingyo 0:dde6e4d8c301 24 pc.attach(&rx_cn);
kangmingyo 0:dde6e4d8c301 25 while(1){
kangmingyo 0:dde6e4d8c301 26 wait(1);
kangmingyo 0:dde6e4d8c301 27 led = !led;
kangmingyo 0:dde6e4d8c301 28
kangmingyo 0:dde6e4d8c301 29 }
kangmingyo 0:dde6e4d8c301 30 }