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.
Dependencies: ds3_si mbed omuni solenoid
Fork of 2017_Robocon_mother by
main.cpp
- Committer:
- gaku_sigu
- Date:
- 2017-09-14
- Revision:
- 2:6c6c5f2796fe
- Parent:
- 1:88d73fd8099a
- Child:
- 3:2d189409c3c3
File content as of revision 2:6c6c5f2796fe:
#include "mbed.h" #include "omuni.h" #include "solenoid.h" I2C i2c(p28, p27); omuni omu(i2c, 0x10, 0x14, 0x16); solenoid sol(i2c, 0x20); Serial con(p9, p10); Serial master(p13,p14); Serial pc(USBTX, USBRX); int ConData[2][12]; void GetData() { if ( con.getc() == 'H' ) { ConData[0][0] = 'H'; for (int i = 1; i < 12; i++) { char t = (char)con.getc(); ConData[0][i] = t; } for (int i = 0; i < 12; i++) { char t = (char)con.getc(); ConData[1][i] = t; } for(int i = 0; i < 12; i++) { master.putc(ConData[0][i]); } for(int i = 0; i < 12; i++) { master.putc(ConData[1][i]); } } } int main() { con.baud(115200); master.baud(115200); pc.baud(115200); con.attach(&GetData,Serial::RxIrq); while(1){ char MotorData[] = {'H', ConData[0][1]-1, ConData[0][2]-6, ConData[1][1]+1, ConData[1][2]-8}; omu.out(MotorData); /* for(int i = 0; i < 12; i++) { pc.printf("%3d ",ConData[0][i]); } for(int i = 0; i < 12; i++) { pc.printf("%3d ",ConData[1][i]); } pc.printf("\n\r"); */ char soldata = ((ConData[0][3] << 2) + ConData[1][3]) << 4; //printf("%d\n",soldata); sol = soldata; } }