Test PS3 - Dribbler
Dependencies: SerialArduino RCJESC
main.cpp
- Committer:
- piroro4560
- Date:
- 2022-06-17
- Revision:
- 0:97e795fb633f
File content as of revision 0:97e795fb633f:
#if 1 #include "mbed.h" #include "esc.h" #include "SerialArduino.h" RCJESC esc(PC_9); DigitalIn myb(PC_3); DigitalOut led(LED1); SerialArduino mini(A0, A1, 115200); uint8_t h1,h2; bool b[12]= {}; uint8_t st[4]= {}; uint8_t tr[2]= {}; void PS3get(bool flag_PS3print); int main() { esc.setspeed(0.0); thread_sleep_for(1200); while (1) { PS3get(false); // if(myb) esc.setspeed(0.7); // else esc.setspeed(0.0); // led = myb; if(b[2]) esc.setspeed(0.7); else esc.setspeed(0.0); led = b[2]; } } void PS3get(bool flag_PS3print) { h1 = mini.getHedder1(); h2 = mini.getHedder2(); for(int i=0; i<12; i++) { b[i] = mini.getButton(i); } for(int i=0; i<2; i++) { tr[i] = mini.getTrigger(i); } for(int i=0; i<4; i++) { st[i] = mini.getStick(i); } if (flag_PS3print) { for(int i=0; i<12; i++) printf("%d ",b[i]); printf("|"); for(int i=0; i<2; i++) printf("%3d ",tr[i]); printf("|"); for(int i=0; i<4; i++) printf("%3d ",st[i]); if(mini.getState()) printf("ok"); else printf("bad"); printf("\r\n"); } else { mini.getState(); } } #endif