Movement Tracking


This experiment tested the reflectance sensors to prove that they are functioning correctly. The sensors are meant to tell the arduino how far the AEV has moved, making them vital in the success of this project. This is done when light bounces off a reflector on one of the wheels and the reflectance sensors count how many times the reflectors reflect the light. This serves as a type of unit of length that can be used in programming how long or short the distance the AEV should go on the track. 

Picture for clarity, reflectance sensors are the two red chips near the top.

Before any testing the reflectance sensor test command is used and ran to ensure the sensors are not faulty. This code is ran by moving the wheel and the code will display the distance traveled and the direction in which it is moving. After the test command the experiment began with securing the sensors to the arm of the vehicle, and then uploading a simple code. The code consists of running the motors until the vehicle has moved 12 feet forward, and then stopping. With the lab complete, the sensors are proven to work and a basic understanding on how to use them will help move the coding forward.

Before explaining each segment of the code for a better understanding of each command please open the programming basics tab and find the glossary at the bottom with all used commands in it for future codes.


Code used:  

Refer here for information on command functions.

Code

Explanation

motorSpeed(4,25); 

goFor(2); 

All of the motors run at 25% power for two seconds so the AEV can start moving.
motorSpeed(4,20); 

goToAbsolutePosition(295); 

The motors continue to run at 20% power until the AEV has traveled a total of 12 feet or 295 marks.
reverse(4);  Reverse the direction the motors will be spinning.
motorSpeed(  4,30); 

goFor(1.5); 

Run all of the motors at 30% power for 1.5 seconds when they are reversed to help stop the AEV quicker, then stop all the motors from moving anymore with the brake command.
brake(4); Stops all motors from running anymore