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: MODSERIAL mbed-rtos mbed
Fork of Master by
control.cpp
- Committer:
- 9uS7
- Date:
- 2014-09-11
- Revision:
- 0:4f07ba929908
- Child:
- 1:e1cfb5850088
File content as of revision 0:4f07ba929908:
#include "mbed.h" #include "control.h" void pull(float buf){ Sig1 = 0; Sig2 = 1; Pwm = zeroPWM+buf/3; } void loose(float buf){ Sig1 = 1; Sig2 = 0; Pwm = zeroPWM+buf/3; } void brake(void){ Sig1 = 0; Sig2 = 0; Pwm = 1; } void open(void){ Sig1 = 0; Sig2 = 0; Pwm = 0; } void ResetPos(){ int pos_flag=0; while(1){ if(Red1>center_pos){ pull(0.3); }else if(Red1<center_pos){ loose(0.3); } if(abs(Red1-center_pos)<0.1){ Open1(); pos1_flag=1; } if(Red2>center_pos){ Back2(); }else if(Red2<center_pos){ Forward2(); } if(abs(Red2-center_pos)<0.1){ Open2(); pos2_flag=1; } if(pos1_flag == 1 && pos2_flag ==1) break; } }