![]() |
Sample Code (Line travel)
Does anyone have a sample algorithm for the autonomous mode (Line travel)? Thanks.
|
Re: Sample Code (Line travel)
Quote:
[code] /* This program will track the left side of a dark line. For this program to work, an IR Reflective Sensor must be attached to Digital I/O Port 6, and must be placed at a height where it reads 0 over a dark surface, and some other number over a light surface. An analog optical sensor may also be used, but the values in the program must be changed to correspond to this light sensor's threshold between light and dark values. */ void Default_Routine(void)/* BEGIN Default_Routine(); */ { if(rc_dig_in06 == 0) /* if dark is seen */ { pwm01=pwm03=127; /* turn left motors off */ pwm02=pwm04=96; /* turn right motors forward slowly */ } else { pwm01=pwm03=159; /* turn left motors forward slowly */ pwm02=pwm04=127; /* turn right motors off */ } printf("%d\n", rc_dig_in06); /* print light sensor readings */ } /* END Default_Routine(); */ [\code] |
| All times are GMT -5. The time now is 00:29. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi