top of page

"Let There Be LIGHT"

Overview:

A photocell can sense its environment and return a digital representation of the level of illumination. We will use this value to check how dark it is outside, and light LEDs accordingly.


Task Goal:

To receive analog input from the photocell, in order to detect the level of illumination in the room. According to the illumination level - some of the LEDs will light up (0-3 LEDs).

(This part assumes that all three LEDs are already set up and connected to GPIOs 11,12,13. Please see previous parts of this tutorial).

 

Electronics:

  1. The Photocell (Photoresistor / LDR - Light Dependent Resistor), is a resistive component that increases or decreases its resistance depending on the light it senses. The resistance value can be read and converted to a digital value using an analog input pin.

  2. Resistor - In our circuit, the resistor will be used to reduce current flow. We will use a single 4.7KOhm resistor.

  3. Jumper Wires (M/M) - We will use 4 of them to connect the Bluefruit-board to the breadboard.

Source Code:

Folder name: part_5_photoresistor
 

Instructions:

  1. It is helpful to have the Bluefruit-LE pin-out open while you work.

  2. Connect the photocell to the breadboard, each leg to a different row (see picture below). The photocell has two legs, and they are symmetric, it doesn't matter to what leg you connect to each row (unlike the buzzer, or the leds we have seen in previous parts of the workshop).

  3. Connect the 3V pin to one of the photocell legs (by connecting it to the same row in the breadboard, with a jumper wire).

  4. In the second leg, two connections shall be done:

    1. First, connect a resistor to this row (see the picture below).

    2. Second, connect an analog pin to this row, using a jumper wire. We will use A0 for that, Pin 18)

  5. Now, connect the other leg of the resistor to the breadboard ground (GND) line. (It is assumed that the GND line of the breadboard is already connected to the Bluefruit board ground (GND) pin. If this is not the case, connect  it as well).


NOTE: In must rooms, two out of the three LEDs shall be light up. Try to cover the area around the photoresistor with your hands, so the area will be darker, as a result, two or three leds shall light up (depending on how dark it is). Try to illuminate on the photoresistor with your phone flashlight, as a result, all LEDs shall be turned off.

 

 

See also:

Arduino's tutorial or Adafruit's tutorial about photocell with Arduino.

 

Your setup shall look like this:

bottom of page