Sections
You are here: Home Documentation How-tos Photocell

Photocell

How to connect and use a photocell (light sensor) with the Make Controller.

Problem

You want to connect a photocell (light sensor) to the Make Controller. 

Photocell

 

Solution

  • Connect the red lead to VIn set to 3.3V.
  • Connect the yellow signal lead to an analog input - the image below shows the photocell connected to In0.
  • Connect the black lead to GND. 

 

Photocell Connected

A photocell connected to Analog In 0 on the Make Controller Kit.

Note that if you're not using a MakingThings photocell, you'll need to add your own resistor to create the correct circuit.  From the signal lead, attach a resistor.  From the top side of the resistor, connect a wire that goes to the analog input.  From the bottom side of the resistor, send that connection to GND.  We use a 1K resistor, but see the discussion below to select a resistor for a more specialized setting.

Discussion

A photocell is a type of resistor that reacts to the level of light falling on it.  When light strikes the cell, current flows more freely and when dark its resistance increases dramatically, limiting the flow of current. The resulting voltage is what gets measured by the analog input of the Make Controller.

Photocells need some calibration to be responsive in particular lighting situations:

  • Detect small fluctuations in light levels to distinguish between one light bulb or two
  • Detect larger fluctuations just to measure direct sunlight and total darkness
  • Anything in between.

Each scenario requires a slightly different voltage divider setup, which we'll get into below.

Circuit

The circuit used is a plain voltage divider. It is used since we need to present a voltage to the Analog In device and the photocell merely changes resistance. As the resistance of the photocell reduces (as more light hits it) the voltage on the analog input will go up towards 3.3V. If the resistance of the photocell increases (less light hits it) the voltage on the analog input will fall towards Gnd (0V).

 

Component Selection

The best way to determine what resistor to use in the voltage divider for this photocell is to take the photocell and an ohmmeter to the setting where you'd like to use it. With the leads of the ohmmeter connected to the photocell in your given light situation, note the measured resistance. This value or one slightly higher will likely be a good value for your resistor.

We measured the photocell available in our store to have a resistance of about 100 in bright sunlight and 500 k in total darkness. If you want to use the photocell to detect when something passed in front of the sun or another bright light source, you would then want to use a lowish value resistor in the voltage divider. Note that 100 is probably a bit too small since (by Ohm's Law) this would result in I = V / R = 5 / 200 = 25mA which is quite a lot. You might consider a minimum resistor value to be 500 - which would result in a full light current of less than 10mA.

Ambient daylight in a room produces a resistance of about 1 k in the photocell. Placing a finger directly over it produced a resistance of about 3 k. If this set of light conditions is appropriate, then a 1 k resistor would be a good choice for the voltage divider. Remember, the purpose of the voltage divider is to provide a counterbalance to the resistance the photocell will have in the light conditions you want.

Log in


Forgot your password?
New user?