Please enter the email address you used on Kickstarter:


MicroView Learning Kit

05 Photo Resistors

Introduction

So you’ve already played with a potentiometer, which varies resistance based on the twisting of a knob. In this circuit, you’ll be using a photo resistor, which changes resistance based on how much light the sensor receives.

Parts

Component Reference Image
Photo Resistor Photo Resistor Diagram

Checkout our breadboard guide and MicroView Pinout for more information.

Breadboard Setup

MicroView Arduino Code

What you should see

You should see the potentiometer value being displayed on the MicroView's display.

Code to Note

A “variable” is a stored value you’ve given a name to. You must introduce, or "declare" variables before you use them; here we're declaring a variable called sensorValue, of type "int" (integer). Don't forget that variable names are case-sensitive!

int sensorValue;

We use the analogRead() function to read the value on an analog pin. analogRead() takes one parameter, the analog pin you want to use ("sensorPin"), and returns a number ("sensorValue") between 0 (0 volts) and 1023 (5 volts).

sensorValue = analogRead(sensorPin);

Troubleshooting

Sporadically Working

This is most likely due to a slightly dodgy connection with the photoresistor's pins. This can usually be conquered by pushing the photoresistor down into the breadboard.

Still No Success?

A broken circuit is no fun, send us an e-mail and we will get back to you as soon as we can: help@geekammo.com

Pull Up Resistors

Many of the sensors you'll use (potentiometers, photoresistors, etc.) are resistors in disguise. Their resistance changes in proportion to whatever they're sensing (light level, temperature, sound, etc.).

The MicroView's analog input pins measure voltage, not resistance. But we can easily read voltage by using the MicroView's internal pull up resistors.

Continue on to circuit 06 Temperature Sensor