When the micro:bit detects darkness, the servo motor springs into motion.
Continuously set the position of the Servo A
to the value of the light sensor, constrained from 0
to 100
(since the light level goes up to 255
).
basic.forever(function () { sb.setServoPosition(sb.servo(SBServo.ServoA), Math.constrain(input.lightLevel(), 0, 100)) })
If using micro:bit for the first time, follow this setup.