Press and hold a button for maintaining a position.
Use a loop to continuously check if Button A
is pressed, and then set the position of the Servo A
to either 0
(when pressed) or 100
(while not pressed).
basic.forever(function () { if (input.buttonIsPressed(Button.A)) { sb.setServoPosition(sb.servo(SBServo.ServoA), 0) } else { sb.setServoPosition(sb.servo(SBServo.ServoA), 100) } })
If using micro:bit for the first time, follow this setup.