Exercise 2 Code & Sensors

Sensors

The reflectance sensors keep track of marks which can be converted into engineering units for distance. The amount of marks can be used to keep track of the distance the AEV travels. This process is helpful as the AEV has to travel along the rail for certain distances to pick up and drop off passengers.

Code

//Run all motors at a constant speed of 25% power for 2 seconds.
motorSpeed(4,25);
goFor(2);

//Run all motors at a constant speed of 20% and using the goToAbsolutePosition function travel a total distance of 12 feet
//(from the starting point).
// You will actually rotate the wheel by hand (since you are on the desktop tracks)
//until the wheel has completed the required distance and the motors stop.
motorSpeed(4,20);
goToAbsolutePosition(295);

//Reverse motors.
reverse(4);

//Run all motors at a constant speed of 30% power for 1.5 second.
motorSpeed(4,30);
goFor(1.5);

//Brake all motors.
brake(4);