Monday, March 18, 2019

Day 18: Introducing the Servo Motor to the Micro:Bit



Adding a Servo Motor to your Micro:bit can expand the potential of your micro:bit.
But I must warn you.. they can be a little finicky, so be prepared for some troubleshooting.

Here's how to get started.






Start with a simple micro:bit Go pack

BBC2546862 Micro:bit go

Next  you'll need  a servo motor.  For our classroom projects we  started with some inexpensive SG90 Micro Servo Motors like these:





SG90 Micro Servo Motor (about $1.50 each)  



Then you'll need some wires to attach the servo motors to the micro:bit.

The easiest way to connect your servo motor to your micro:bit is to use three premade wires like these croc-clip to jumper wire (male) 


But if you have alligator clips and jumper cable,  you can make your own - like this





Most standard servos have three wires, each a different color. 

It's important to know that the color of the wire indicates how it should be communicated to your micro:bit 


  • brown or black = ground  and should connect to the -negative or GND connector 
  • red = servo power  and should connect to the + Positive or 3V connector
  • orange, yellow, white, or blue = servo control and will connect to pin 0, 1, or 2 on your micro:bit
Unfortunately, the servo as a 3 prong female connector, so you'll need a way to attach each of these colored wires to the microBit.   Here is where your croc to male alligator clips come in handy. 


I like to color code my alligator clips, so I selected a BLACK, RED, and YELLOW tipped Alligator Clip

Then I connected my
 BLACK tipped alligator clip to the BROWN/Black Servo wire
 RED tipped alligator clip to the RED servo wire
YELLOW tipped alligator clip to 'other color' SERVO wire
      depending on your Servo wire, the other color may vary. Mine is orange this time.




Next connect your GND (Black) alligator Clip to your Micro:bit GND pin

Connect your RED +3V alligator Clip to your micro:bit 3V pin

and Finally connect your 'other colored' - (YELLOW) to PIN (0) on your micro:bit

Any pin  (0, 1, 2) would work, but let's start with PIN 0.







TEST your Servo 


The next step will assume that you know how to create simple code using MakeCode and download it to your micro:Bit to run it.

If you want to test your servo motor connection you can try to create this simple program, which will allow your servo motor to change directions based on how you tilt your micro:bit.





You will find the RED commands under ADVANCED and PINS

And the purple Acceleration command under INPUT


Or you can download TEST SERVO CODE hex file here!


IMPORTANT: servo motors require significant power.
Test the code with your micro:bit connected to your computer.
Now Test the code with our micro:bit running on battery.
Notice the difference in power.

If your servo code is not working as expected, always test with your micro:bit being powered with your computer, to see it the problem is not a lack of sufficient power from the battery pack. 


NEXT STEP!  Calibrate your Servo.


Use the code found on this page to see if you can change your servo by pressing the A and B buttons

You can download the code from this page




My first challenge was to understand the way the servo motor records angles.  By creating this very simple project,  I got a much better understanding of how to control my servo motor. 

I grabbed an empty box, and created a cut out for the MicroBit. 

Then I attached the servo motor so that its plastic arm pointed toward the center of the box. 

Finally I created a graphic with the letters A,   B,  and AB. 

The challenge was to write code that positioned the arm next to A, when you pressed button A,  and for the arms to point to B when you pressed Button B, and then point to AB . when you pressed both buttons (A and B) 



Once you are able to complete this challenge, you'll have have a better grasp on how to control your servo motor with a microBit. 

Our next challenge is to create a game that uses the servo motor in some way.

Here is the game I created.   What would you create?







2 comments:

  1. Why People Play Satta King
    The craze of installing Satta King Online in India is increasing among the people. Despite the police and administration’s rein, people play satta matka secretly. Today many people play Online Satta to avoid the police. Nobody gets to know about them by this.

    Satta Matka is a kind of lottery game, it started in America but it has become very popular in India as well. It is a kind of speculative game. It is called Matka because in the old times numbers were added to Matka. It is illegal in India to play satta matka but people still play it.

    How to play Satta king

    There are many numbers in Satta king, out of which a lottery comes out only on a unique number, if your number goes out, you will be rewarded, if not it will lose all the money.

    Play Satta king online

    Due to the expansion of technology, now many types of Satta king online 2019 are played online and even many of its apps are present. People also play this game online to avoid the police as there are very few chances of getting caught.

    There are many types of Sattaking

    Many types of Sattaking games are played in India such as Kalyan Matka, Kubera Matka, The P Boss, Man Mumbai Matka, Indian Matka, Wali Matka, Super Day Matka, Boss Matka, Kubera Matka, Madhur Matka, Black Satta, Gali Diswar, Guru Delhi, Mayapuri, Delhi King, Mumbai Morning etc.

    The craze of installing Satta King Online in India is increasing among the people. Despite the police and administration’s rein, people play satta matka secretly. Today many people play Online Satta to avoid the police. Nobody gets to know about them by this.

    Satta Matka is a kind of lottery game, it started in America but it has become very popular in India as well. It is a kind of speculative game. It is called Matka because in the old times numbers were added to Matka. It is illegal in India to play satta matka but people still play it.

    How to play Sattaking Result

    There are many numbers in Sattaking Result, out of which a lottery comes out only on a unique number, if your number goes out, you will be rewarded, if not it will lose all the money..satta king online result

    ReplyDelete