Atsumi Toda
/
twe-_lite_receive
twe-liteを使った受信プログラム。透過モードに非ず。
main.cpp
- Committer:
- Joeatsumi
- Date:
- 2018-02-18
- Revision:
- 0:b2737a0c9620
File content as of revision 0:b2737a0c9620:
#include "mbed.h" Serial twe(p9, p10); // tx, rx Serial pc(USBTX,USBRX); char rpm_array[5] = "0000";//実は末尾にnullがあるので、要素が4つでも配列では5つの箱を用意している char dam; int rpm=0; DigitalOut myled(LED1); void rpm_f()//文字列から数値への変換 { rpm = atoi(rpm_array); rpm-=1000; } int main() { twe.baud(115200); pc.baud(115200); while(1) { if(twe.getc()==':'){ if(twe.getc()=='0'){//送信してきた相手のIDは0x01 if(twe.getc()=='1'){ dam=twe.getc();//数値とは関係ないのでdamに入れて無視をする dam=twe.getc();// for (int i = 0; i <= 4; i++) { rpm_array[i] =twe.getc();//高度の受信rpm+1000の値を文字列として受け取る } } } } rpm_f(); pc.printf("Rpm=%d",rpm); }//while }//int main()