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


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) {
    } else {


To buy electronic components order from UTSOURCE

1 thought on “LDR with BBC micro:bit”

Leave a Comment

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