View Single Post
  #2   Spotlight this post!  
Unread 22-02-2009, 20:49
dooey100 dooey100 is offline
Registered User
FTC #3037
 
Join Date: Feb 2009
Location: Fernie
Posts: 47
dooey100 is on a distinguished road
Thumbs up Re: [FTC]: Light Senser

here is some basic code that will drive until your sensor hits the line:

Code:
motor[drive_right] = 100;       //start driving the motors
motor[drive_left] = 100;
while (SensorRaw[lightSensor] < tapeColor);      //keep driving until you run over the tape, tapeColor is a variable determined by the lighting and color of the tape, we used 340.
motor[drive_right] = 0;       //stop
motor[drive_left] = 0;

following the line is a bit tougher, the general idea is to go straight unless the light sensor goes off the line, if it does, turn until it is on the line again. Good luck getting it working, and if you need another hint, just ask!

Last edited by dooey100 : 22-02-2009 at 20:53.
Reply With Quote