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-06
- Revision:
- 0:738a25907be7
- Child:
- 1:8535eef790f1
File content as of revision 0:738a25907be7:
#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 cross; while(1){ circle = ps3.getButtonState(maru); cross = ps3.getButtonState(batu); char ninty = 0x01; char zero = 0x02; char nosignal = 0xff; char add = 0x18; if(circle == 1){ send(add,ninty); pc.printf("0x01\n"); }else if(cross == 1){ send(add,zero); pc.printf("0x02\n"); }else{ send(add,nosignal); pc.printf("0xff\n"); } } } void send(char address,char data){ i2c.start(); i2c.write(address); i2c.write(data); i2c.stop(); }