Site icon DIY Usthad

LDR with BBC micro:bit

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.inAmazon.comBanggood.comAliExpressUtsource
BBC micro:bit
LDR
Resistors(10k)

Circuit

Block Code

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

Exit mobile version