|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#2
|
|||||
|
|||||
|
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] |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Autonomous Code From Experience | EbonySeraphim | Programming | 7 | 14-03-2003 21:56 |
| Sprockets and Roller Chain Models | Madison | Inventor | 3 | 04-02-2003 11:51 |
| Does your team use the Default code. | Jeff McCune | General Forum | 2 | 09-01-2003 14:46 |
| iParts on firstcadlibrary.com | Ed Sparks | Inventor | 3 | 08-01-2003 23:30 |
| approach to autonomy | Mike375 | Programming | 32 | 08-01-2003 14:04 |