Bedside Light

Uses

pins, light dependent resistor (LDR), LED light

Description

../../_images/bedside-light2.jpg

In this project, you will be creating a bedside light where it will light up automatically when there is not enough light, and turn off if there is enough light in the room. You will be using a light dependent resistor (LDR) in this activity, which changes resistance across its terminals depending on the amount of light. You will also need a resistor connected on one terminal of the LDR. This resistor is where you will measure the resistance using the pin0 of your microbit across the resistor. The LED light is connected to the pin1 of your microbit. Use also a resistor in series with the LED light to prevent it from overheating. Here is the illustration.

../../_images/bedside-light.jpg

The voltage in pin0 will increase when there is more light, as the LDR will have lower resistance. Conversly, it will have less voltage on pin0 when there is less light as the LDR resistance will increase.

Basic Task

  1. Read analog signal on pin0. The higher the reading (max is 1024), the higher the voltage. You might need to calibrate the value first, so you can use the print() command to print out the measurement to the REPL and try out with lights turned on and off.
  2. Compare measured value with your threshold value based on your calibration. This will determine if you need to turn off or on the LED.
  3. Send a high signal (.write_digital(1)) to pin1 when there is not enough light, and a low signal if there is enough light.