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: SerialMultiByte QEI omni_wheel PID R1370MeasuringWheel IRsensor ikarashiMDC_2byte_ver
main.cpp
00001 #include"mbed.h" 00002 #include"SerialMultiByte.h" 00003 #include"pin_config.h" 00004 00005 SerialMultiByte sita_s(S_SERIALTX,S_SERIALRX); 00006 SerialMultiByte ue_s(U_SERIALTX,U_SERIALRX); 00007 DigitalIn start(USER_BUTTON); 00008 Serial pc(USBTX,USBRX,115200); 00009 00010 DigitalOut debug_led_0(LED0); 00011 DigitalOut debug_led_1(LED1); 00012 DigitalOut debug_led_2(LED2); 00013 DigitalIn debug_button(PC_4); 00014 00015 int mode=0; 00016 int u_mode=0,s_mode=0,m_mode=0; 00017 unsigned char itidata[4]; 00018 int X_,Y_; 00019 int data_a; 00020 00021 void to_sita(){ 00022 unsigned char data[5]; 00023 unsigned char getdata[1]; 00024 data[0] = mode; 00025 for(int i=0;i<4;i++){ 00026 data[i+1] = itidata[i]; 00027 } 00028 sita_s.sendData(data,5); 00029 sita_s.getData(getdata); 00030 s_mode = getdata[0]; 00031 } 00032 00033 void to_ue(){ 00034 unsigned char data[1]; 00035 unsigned char getdata[5]; 00036 data[0] = mode; 00037 ue_s.sendData(data,1); 00038 ue_s.getData(getdata); 00039 u_mode=getdata[0]; 00040 for(int i=0;i<4;i++){ 00041 itidata[i] = getdata[i+1]; 00042 } 00043 } 00044 00045 00046 int main() 00047 { 00048 sita_s.setHeaders('A','Z'); 00049 sita_s.startReceive(1); 00050 ue_s.setHeaders('A','Z'); 00051 ue_s.startReceive(5); 00052 debug_button.mode(PullDown); 00053 while(1) 00054 { 00055 debug_led_0 = !debug_led_0; 00056 to_ue(); 00057 to_sita(); 00058 if(!start)mode = 1; 00059 if(mode==1&&s_mode ==2)mode = 2; 00060 if(mode == 2&&u_mode == 0xff &&s_mode == 0xff)mode = 3; 00061 if(mode == 3&&u_mode == 0xff &&s_mode == 0xff)mode = 5; 00062 00063 00064 } 00065 00066 00067 return 0; 00068 }
Generated on Sat Aug 20 2022 11:34:06 by
1.7.2