Home           Info Request           Quote/Order           Contact           Site Map           About           Search           Support/FAQ  

 ARobot Light Detector Application Note
Back to ARobot Projects Page

This application note in PDF format

Light Detector on ARobot

This application explains how to make a light detector for ARobot. This can be used to tell when a light is on or off, whether the robot is inside or outside, or for light following. This is a simple expansion and does not require soldering if using a breadboard. It does assume that you have attached a breadboard and an expansion cable to the ARobot (see the breadboard/perfboard application note). This circuit and the light sensor could be mounted and soldered to a perf board and located to a movable head. Multiple light detector sensors could be used to detect the direction of light.

      Parts List
These parts can be found at Radio Shack http://www.radioshack.com , Mouser Electronics http://www.mouser.com or Digi-Key http://www.digi-key.com.

Light detector (CDS photocell)       #276-1657     $2.29
47 uF capacitor, 16 volts or more    #272-1027     $.69
You can use an CDS photocell but you may need to change the capacitor value and the timing in the software. Experimentation will be needed.


The CDS sensor acts like a variable resistor. As the incoming light changes, the resistance of the CDS cell changes. If the resistance level could be determined then the light level could also be determined. One way to "read" the resistance with a microcontroller is to time how long it takes to charge a capacitor through the resistor(a CDS cell in this case). First the capacitor must be drained (remove all charge). Then the capacitor is left to charge up. If the resistor has a low value, the capacitor will charge quickly. If the resistor has a high value, the capacitor will charge slower. This time is measured in software to determine the CDS resistance .

CARE MUST BE TAKEN when hooking up the capacitor to the circuit. The negative lead is labeled on the capacitor. This lead should go to GND. If the capacitor is hooked up incorrectly it could explode. If power is applied to an incorrectly wire capacitor that capacitor should be thrown away. Make sure that the capacitor has a voltage rating of 16 volts or more.

The detector can be modified to be more directional. Electrical tape can be wrapped around it to create a tube. When aimed at a light then the light will be detected. When pointed away the light will not be detected.

There are several other sensors that act like variable resistors. One such application uses a thermister which changes resistance with changes of temperature. This could be used to allow ARobot to respond according to the temperature.

NOTE: The resistor/capacitor charge rate is exponential not linear.

Incorporate light detection in almost any ARobot program using the following example program as a guide.

You can download this program here.

'ldetect.bs2    Arrick Robotics  
'               www.robotics.com
'This routine demonstrates detecting 
'light using a CDS cell.  The light level
'is read by determining the time it takes
'to charge the capacitor.  The CDS cell
'changes resistance as the light intensity 
'changes.  This changes the current that 
'charges the capacitor.  The time is
'measured and the output result is then
'displayed to the debug screen.

light   var     word    'Light variable.

        pause 500    'check each 1/2 sec.

        low 2            'drain cap.
        pause 50   'wait for cap to drain.
        rctime 2,0,light 'Find time.

        debug ? light    'Display.

        goto    main     'do forever.

Here's are some useful sources for parts:

  Home           Info Request           Quote/Order           Contact           Site Map           About           Search           Support/FAQ  
Copyright (c) Arrick Robotics - ArrickRobotics.com