LDR with BBC micro:bit

Let’s learn to use an LDR sensor or photoresistor with BBC micro:bit.

This is a very simple project. We are going to print “BRIGHT” in the inbuild LED matrix of the micro:bit if there is light in the room or else “DARK” will be printed.

Hardware Required

ComponentsAmazon.inamazonAmazon.comamazonBanggood.combanggoodAliExpressali expressUtsourceutsource
BBC micro:bitcart iconcart iconcart iconcart iconcart icon
LDRcart iconcart iconcart iconcart icon
Resistors(10k)cart iconcart iconcart iconcart iconcart icon

Circuit

BBC micro:bit with LDR (photoresistor) sensor
  • Connect one of the terminal of LDR to the pin 0 of the micro:bit.
  • Then connect the other terminal of the LDR to the 3v of micro:bit.
  • Finally, connect a 10k resistor in-between ground of the micro:bit and the pin 0.

Block Code

block code for using LDR with BBC micro:bit

JavaScript Code


basic.forever(function () {
    if (pins.analogReadPin(AnalogPin.P0) <= 1000) {
        basic.showString("DARK")
    } else {
        basic.showString("BRIGHT")
    }
})

Video

To buy electronic components order from UTSOURCE

2 thoughts on “LDR with BBC micro:bit”

  1. The article “LDR with BBC micro:bit” provides a concise and informative guide to using an LDR (Light Dependent Resistor) with the BBC micro:bit. The title clearly indicates the topic, making it easy for readers interested in microcontroller projects involving light sensing. The content likely explains the setup, connections, and coding required to interface an LDR with the micro:bit board. This article appears to offer practical insights for beginners and enthusiasts looking to experiment with sensor-based projects using the micro:bit platform.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top