from microbit import *
while True: #loop code
pin0.write_digital(1)
sleep(4000)
pin0.write_digital(0) sleep(4000)
from microbit import * while True: pin0.write_digital(1) sleep(4000) pin0.write_digital(0) sleep(4000)
Source Link: https://techtutorialsx.com/2019/04/07/microbit-micropython-controlling-a-dc-motor/