Trigger the servo's motion when moving the micro:bit.
Continuously monitor the acceleration strength
for motion detection. If it goes over 1200
, transition the Servo A
position back and forth.
basic.forever(function () { if (input.acceleration(Dimension.Strength) > 1200) { sb.transitionServoPosition(sb.servo(SBServo.ServoA), 100, 1, sb.easing(SBEasing.Linear)) sb.transitionServoPosition(sb.servo(SBServo.ServoA), 0, 1, sb.easing(SBEasing.Linear)) } })
If using micro:bit for the first time, follow this setup.