Create a motion detecting alarm.
Continuously turn off the RGB LED A
and monitor the acceleration strength
for motion detection. If it goes over 1200
, turn on the RGB LED A
for 4 seconds.
basic.forever(function () { sb.setRgbLedColorRGB(sb.rgbLed(SBRgbLed.RgbLedA), 0, 0, 0) if (input.acceleration(Dimension.Strength) > 1100) { sb.setRgbLedColorRGB(sb.rgbLed(SBRgbLed.RgbLedA), 100, 0, 0) basic.pause(4000) } })
If using micro:bit for the first time, follow this setup.