|
Re: hey need some help with writing a code please help me here
well, what sort of sensors are you using and in what places? is it just a limit switch on the front? if so, how are you trying to make sure you go the right direction? Or is it just trial and error? Assuming trial and error with limitswtches on the fron i would do something like this:
Code:
char turning=0; //in the global vars section
if (BUMP_SENSOR = 1) //if hit wall set turning timer
then
turning=40;
else if (turning >= 35) //back up first 6 cycles or so to give clearance
then
{
pwm01=pwm02=70;
turning--;
}
else if (turning != 0) //turn for the remaining time
then
{
pwm01=77; //assuming 2 motor drive train here
pwm02=187; //adjust values as necessary such as time needed to turn and turning speed
turning--;
}
else
pwm01=pwm02=200; //if not turning or hitting go forward
i hope this helps, but i really need some more details.
-Kesich
__________________
C is screwing up my English--I'm ending all my sentences in semi-colons;
Horray for most things! -George Carlin
"Sure, I'll play rugby. Besides, I have a lot of experience running from really big guys who want to cream me." -Me, Freshman year
|