Photoresistors (Photocell) Sensors

1. Overview

2. Connecting the photoresistor to the Handy Board

3. Software Interface

1. Overview

Photoresistors (photocells) are simply variable resistors in many ways similar to potentiometers, except that the resistance change in light level rather than by turning a knob. Photoresistors can be used as light sensors, which can enable robot behaviors such as hiding in the dark, moving toward a beacon, etc.


2. Connecting the photoresistor to the Handy Board

The photoresistor sensor wiring makes use of the on-board 47K ohm resistor that connects the sensor signal line to +5V. When wired from the signal line to ground, the photocell becomes part of a voltage divider circuit as shown in fig 2. The total resistance in this circuit, RT, is the sum of the individual resistances: RT= R + RL. According to Ohm's law, the current, I, through the circuit is I =V/RT. In order for the A/D converter in the microcontroller to measure a voltage, some current must flow into the pin of the microprocessor. However, since the amount of such current is negligible compared to the currents in the rest of the circuit. In this case, the connection to the microprocessor can be ignored while analyzing the voltage divider. Thus, the voltage present on the analog input is:

V in = I * RL

Subsituting I iwth I=V/RT=V/(R+RL), we get

V in = V*RL/(R+RL)

The resistance of the phototransistor falls as the light level increases. The A/D converter in the 68HC11 can then map the variable voltage, V in, into the range 0 to 255.


3. Software Interface

Software interface for the photocell is very simple. The command,

int analog(int p)

returns the value of the sensor port numbered p. The result is an integer between 0 and 255. The ports are numbered as marked on the Handy Board.