Direction Detection Algorithm

For detecting the direction the robot is travelling, we use a reflectance sensor.

The sensor returns 0V if it sees a white surface, and a higher voltage value if it sees a black surface. The program uses an external interrupt. When the IR reflectance sensor detect a digital signal of voltage drop, the interrupt stores the clock time in the microcontroller. Then compares the length of the two recorded clock time to determine the direction the robot is traveling. Secondly it counts the number of times it has passed a group of white sections to determine how many laps the robot has completed.

If the robot detects an incorrect direction, it will begin a three point turn maneuver. When it detects that 5 laps have passed, it will stop the motor.

This video shows the reaction of the robot when incorrect direction is detected:

This entry was posted in Software Design and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *