Anish Ansari
Published © GPL3+

How to Control Mini Servo Using BBC Micro:bit

At the end of this article, you will have complete knowledge of how you can control a mini servo using a BBC micro:bit.

BeginnerFull instructions provided30 minutes13,048

Things used in this project

Hardware components

BBC micro:bit board
BBC micro:bit board
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1
AA Batteries
AA Batteries
×2
Male/Male Jumper Wires
×3
Servos (Tower Pro MG996R)
×1

Software apps and online services

pxt.microbit.org
micro:bit pxt.microbit.org
MakeCode
Microsoft MakeCode
Microsoft MakeCode for MICRO:BIT

Story

Read more

Code

Javascript code

JavaScript
basic.forever(() => {  
    while (true) {  
        pins.servoWritePin(AnalogPin.P0, 45)  
        basic.pause(1000)  
        pins.servoWritePin(AnalogPin.P0, 90)  
        basic.pause(1000)  
        pins.servoWritePin(AnalogPin.P0, 180)  
        basic.pause(1000)  
    }  
})  

Credits

Anish Ansari

Anish Ansari

11 projects • 42 followers
Azure and IoT

Comments