Skip to content

LDR Light Sensor

An LDR (Light Dependent Resistor), also called a photoresistor, changes its resistance based on the amount of light falling on it. This allows your micro:bit projects to measure brightness and respond to changes in ambient light.


What It Does

The LDR outputs a varying voltage depending on light intensity. Your program can read this as an analog value (ranging from dark = low value to bright = high value) and use it to trigger actions such as turning on lights or adjusting displays.


Real-World Applications

Light sensors are used in countless real-world systems, such as:

  • πŸ’‘ Automatic Street Lights – Turning on at night and off in the morning.
  • πŸ“± Smartphones – Adjusting screen brightness based on ambient light.
  • 🏠 Smart Homes – Controlling curtains, lamps, or garden lighting automatically.
  • πŸ€– Robotics – Light-following robots or obstacle detection.
  • πŸ”’ Security Systems – Detecting changes in light for alarms or monitoring.

Using an LDR, students learn how to make their prototypes react intelligently to environmental light conditions.

βœ… With the LDR, you can build projects that respond to lightβ€”from night lamps and alarms to smart energy-saving devices.


Connection to the breakout

  • Connect the LDR to the port 3v3, GND and P2 (Blue) LDR connection port

  • Connect the OLED to the port P20, P19 , GND and 3v3 (Yellow) OLED connection port

  • Connection of LDR and OLED with the breakout board

LDR and OLED connection


Code