decorative bevel

Light Sensing

Description

This example details reading in an analog value from a light sensing circuit. The circuit sends a signal to the Cerebellum between 0 and 5 Volts, corresponding to the ambient light level at the sensor. The provided Cerebellum program reads the signal and stores it as an eight bit integer, with a value ranging from 0 to 255. A value greater than 127, or 2.5V, will cause the Cerebellum LED to turn on. The value will also be printed over the serial port to any open computer terminal program.


Materials

To try this at home, you will need:
  • A Cerebellum
  • A power source (the provided DC adapter will work fine)
  • One photoresistor (~200 Ohms in ambient light)
  • One 330 Ohm resistor
  • A breadboard

Photoresistor Circuit

A photoresistor varies its resistance according to the amount of light hitting its surface - as more light hits the photoresistor, it's resistance decreases. In this sensing circuit, +5V is connected to one lead of the photoresistor, while the other lead connects to a fixed value resistor, the other lead of which is grounded. This forms a voltage divider that creates a signal voltage which varies according to the following equation:

signal voltage = 5V * (330 Ohms/photoresistor value+330)

Code

You will need the following to compile this program:

References

Check out the following pages in the manual for more information: