View Single Post
  #23   Spotlight this post!  
Unread 03-03-2004, 23:14
JBabbie's Avatar
JBabbie JBabbie is offline
Registered User
#0201
 
Join Date: Mar 2004
Location: Michigan
Posts: 10
JBabbie is on a distinguished road
Talking Re: How do u get your robot to follow the white line??????????????????

ok , you need 2 banner cells, one of the left or your bot (l_banner) . and one on the right (r_banner)

if ( l_banner == 1)
turn robot left 45 degrees ( run trial and error tets to find out how long it takes to turn your bot 45 degrees left)
if (r_banner == 1)
turn your robot right 45 degrees

so... if you had 4 wheel tank drive , and your left drive motors were pwm01 & pwm02 , and your right were pwm03 & pwm04. and run a counter ((int)count_me)
Code:
 if (l_banner == 1)
 {
 count_me ++ ; 
       if (count_me <=2)
         {
          pwm01 = pwm02 =  200; /* runs your left motors at a medium 
                                                speed forward */
          pwm03 = pwm04 = 75;   /*runs your right motors at a medium speed 
                                              reverse */
          }
      if(count_me >=3)
        {
         count_me = 0; /*resets the counter */
        }
}   
else  
if (r_banenr == 1)
 {
 count_me ++ ;
      if (count_me <= 2)
        {
         pwm01 = pwm 02 = 75; /*left motors run reverse */
         pwm03 = pwm04 = 200; /*left motors run forward */
        }
        if (count_me >= 3)
        {
        count_me = 0; /* resets the counter */
        }
}
else
 pwm01 = pwm02 = pwm03 = pwm04 = 255 ;  /*runs robot full forward */
keep in mind that the values I gave the motors and the counter are guesses , you might want to play with those on your own =), and also ... thats for a tank drive robot.. so if you use that.. keep your wheels pointed straight if you have swivel drive

fixed the indentation =)

Last edited by JBabbie : 04-03-2004 at 13:31. Reason: forgot part