Code
Duration: ~30 minutes
Step 1: walk forever
In order for the inchworm to move, the micro:bit needs to command the servo to move between 0 and 180 degrees at a certain pace. The code below starts the inchworm moving when the A button is pressed.
input.onButtonPressed(Button.A, function () { pins.servoWritePin(AnalogPin.P0, 0) basic.pause(500) pins.servoWritePin(AnalogPin.P0, 180) basic.pause(500) }); NEXT: Connect