Introduction
Light-dependent resistors are electronic components whose resistance changes with light intensity. They are also called LDRs, photoresistors, or photoconductors.Â
In this guide, you will learn to connect a light-dependent resistor to the micro:bit, and measure the relative brightness of the environment.
Complete this guide to learn how to use a light-dependent resistor. They are used in all sorts of light-sensing circuits; For instance, they could be used as a sensor in cameras or automatic lights that come on when it gets dark enough.
-
-
-
-
-
-
-
let threshold = 0 let sensorVal = 0 basic.forever(function () { sensorVal = pins.analogReadPin(AnalogPin.P1) threshold = 500 basic.showNumber(sensorVal) })
-
let threshold = 0 let sensorVal = 0 basic.forever(function () { sensorVal = pins.analogReadPin(AnalogPin.P1) threshold = 400 basic.showNumber(sensorVal) if (sensorVal > threshold) { basic.showIcon(IconNames.SmallDiamond) } else if (sensorVal <= threshold) { basic.showIcon(IconNames.Target) } })
-