SerialArduino

Dependencies:   SerialArduino

Committer:
THtakahiro702286
Date:
Thu Jun 09 08:14:47 2022 +0000
Revision:
1:f64517e88878
Parent:
0:816cb0f3dcd4
Serial Arduino

Who changed what in which revision?

UserRevisionLine numberNew contents of line
THtakahiro702286 0:816cb0f3dcd4 1 #include "mbed.h"
THtakahiro702286 0:816cb0f3dcd4 2 #include "SerialArduino.h"
THtakahiro702286 0:816cb0f3dcd4 3
THtakahiro702286 0:816cb0f3dcd4 4 SerialArduino mini(PC_10,PC_11,115200);
THtakahiro702286 0:816cb0f3dcd4 5 BufferedSerial pc(USBTX,USBRX,115200);
THtakahiro702286 0:816cb0f3dcd4 6
THtakahiro702286 0:816cb0f3dcd4 7 int main()
THtakahiro702286 0:816cb0f3dcd4 8 {
THtakahiro702286 0:816cb0f3dcd4 9 uint8_t h1,h2,i;
THtakahiro702286 0:816cb0f3dcd4 10 bool b[12]={0};
THtakahiro702286 0:816cb0f3dcd4 11 uint8_t t[2],s[4];
THtakahiro702286 0:816cb0f3dcd4 12 char CRLF[3] = "\r\n";
THtakahiro702286 0:816cb0f3dcd4 13 while(1)
THtakahiro702286 0:816cb0f3dcd4 14 {
THtakahiro702286 0:816cb0f3dcd4 15 h1 = mini.getHedder1();
THtakahiro702286 0:816cb0f3dcd4 16 h2 = mini.getHedder2();
THtakahiro702286 0:816cb0f3dcd4 17 for(i=0;i<12;i++)
THtakahiro702286 0:816cb0f3dcd4 18 {
THtakahiro702286 0:816cb0f3dcd4 19 b[i] = mini.getButton(i);
THtakahiro702286 0:816cb0f3dcd4 20 printf("%d ",b[i]);
THtakahiro702286 0:816cb0f3dcd4 21 }
THtakahiro702286 0:816cb0f3dcd4 22 printf("|");
THtakahiro702286 0:816cb0f3dcd4 23 for(i=0;i<2;i++)
THtakahiro702286 0:816cb0f3dcd4 24 {
THtakahiro702286 0:816cb0f3dcd4 25 t[i] = mini.getTrigger(i);
THtakahiro702286 0:816cb0f3dcd4 26 printf("%3d ",t[i]);
THtakahiro702286 0:816cb0f3dcd4 27 }
THtakahiro702286 0:816cb0f3dcd4 28 printf("|");
THtakahiro702286 0:816cb0f3dcd4 29 for(i=0;i<4;i++)
THtakahiro702286 0:816cb0f3dcd4 30 {
THtakahiro702286 0:816cb0f3dcd4 31 s[i] = mini.getStick(i);
THtakahiro702286 0:816cb0f3dcd4 32 printf("%3d ",s[i]);
THtakahiro702286 0:816cb0f3dcd4 33 }
THtakahiro702286 0:816cb0f3dcd4 34 // printf("%d",mini.getRawButton());
THtakahiro702286 0:816cb0f3dcd4 35
THtakahiro702286 0:816cb0f3dcd4 36 if(mini.getState()) printf("ok");
THtakahiro702286 0:816cb0f3dcd4 37 else printf("bad");
THtakahiro702286 0:816cb0f3dcd4 38 printf("\r\n");
THtakahiro702286 0:816cb0f3dcd4 39 thread_sleep_for(10);
THtakahiro702286 0:816cb0f3dcd4 40
THtakahiro702286 0:816cb0f3dcd4 41 }
THtakahiro702286 0:816cb0f3dcd4 42 }