Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- adaemon
- Date:
- 2019-06-17
- Revision:
- 1:8535eef790f1
- Parent:
- 0:738a25907be7
File content as of revision 1:8535eef790f1:
#include "mbed.h" #include "PS3.h" I2C i2c(PB_9,PB_8); PS3 ps3(D8,D2); DigitalOut led(LED1); Serial pc(USBTX,USBRX); void send(char address,char data); int main(void){ i2c.frequency(100000); int circle; int old_circle; //int cross; int memo = 0; char ninty = 0x01; char zero = 0x02; char nosignal = 0xff; char add = 0x18; while(1){ circle = ps3.getButtonState(maru); if(circle != old_circle){ old_circle = circle; if(circle == 1 && memo == 1){ send(add,ninty); memo = 0; }else if(circle == 1 && memo == 0){ send(add,zero); memo = 1; }else{ send(add,nosignal); } }/*else{ send(add,nosignal); }*/ //cross = ps3.getButtonState(batu); /*pc.printf("%4d:%4d\n",circle,memo_servo); if(circle == 1 && memo_servo == 1){ send(add,ninty); memo_servo = 0; wait(3); }else if(circle == 1 && memo_servo == 0){ send(add,zero); memo_servo = 1; wait(3); }else{ send(add,nosignal); }*/ } } void send(char address,char data){ i2c.start(); i2c.write(address); i2c.write(data); i2c.stop(); }