Browse over 10,000 Electronics Projects using the Page Numbering provided at the bottom of each Page.

LightRover – light sensing robot

LightRover – light sensing robot

LightRover is a robot that can sense and follow light. A user can shine a flashlight at its front and LightRover will respond by following the light source. Its speed is dependent upon the intensity of the light detected. LightRover uses a microcontroller for processing the sensor readings and responds by controlling the motors.

LightRover has two major modes of operation: calibration, and follow. These modes are controlled by the main state machine. This organization, combined with the needfor timed motor, sensor, and LED control naturally lead to a timed based scheduler program. Only one ISR was necessary-Timer0 Clear on Compare Match, which interrupts every 1 ms and updates the timers used in the program. Our full feature set had four modes: Calibration, Follow, Menu, Program. However, we decided that working for a stable Follow Mode was more important than additional features, so Program, and Menu Modes were not included in the final design. 

# Program Design Philosophy 
Before writing any code, we sat down and discussed features we wanted to see and how they should work. Since the different features would use the same functions (such as sensing and motor control), our focus was to develop those functions to be as general as possible. For example, we have one function motorControl that takes in a desired direction (foward, left, right, stop) as a parameter and outputs the appropriate control signals. This allows the caller to specify its own timing. 

# Initialization 
The code will initialize various values, state variables, as well as Timer0 and the ADC upon booting. All these initializations are wrapped in the function initialize. When the initializations are complete, the code falls into the main while loop, where it stays for the remainder of the execution. LightRover’s first action is to begin in calibration mode, where it will attempt to adjust to its surroundings. 

# Calibration Mode 
As previously mentioned, when the boot process concludes it enters Calibration Mode. This mode has three states: CALIB_INIT, CALIB_CHECK, and CALIB_DONE, and the state changes at 1.5 second intervals. Typically we begin in state CALIB_INIT to take an initial sensor reading and change to state CALIB_CHECK. 1.5 seconds later, in CALIB_CHECK, we take another sensor reading and compare it with the value previously obtained in CALIB_INIT. If the two results are deemed equivalent, the threshold value is calculated. We calculate the threshold light intensity to be 7% greater than the measured light. This requires a floating point multiply, which we are able to do because this mode is not time critical, and the states have a long 1.5 second interval. The read and comparison cycle is done first for the left sensor, then for the right; with LED’s indicating the sensor. If the comparison fails (if there is a flickering light in the area, for example) then a retry counter is incremented and the process begins over again. However, if there are more than three consecutive calibration failures, the default threshold values are loaded and the program falls into Follow Mode. 
This mode is in function calibrate. We discussed how the robot should handle different light environments and decided that it would be best for the robot itself to set itself. Calibration works very well, but one issue it does not address is what to do when there is too much light and we need to decrease the threshold value. It is very difficult to discern a very bright environment from a constant light signal. We were unable to come to a solution without making judgements on the usage of the robot (What if the user wished to have the robot follow the sun?).

Visit Here for more.