I Like to Move it Move it: Adding Motors to the Makey:bit

30-60 min

Ages 11+

What Will You Make?

Learn how to control servo motors with the micro:bit then build a small buggy for the Makey:bit.

What Will You Learn?

Learn how to install and control Servo motors with the Makey:bit.

Learn how to install Extensions in MakeCode.

Learn how to use Function blocks in MakeCode.

Connect the Servo Motors

Step 1

Look on the back of the Makey:bit at the array of pins behind the head. On the left side of the array, there are two rows of 3 pins dedicated to servo motors. The top row is labeled (left to right) P2 Servo, BAT and GND. The second row is labeled P0 Servo, BAT, GND.

Step 2

Insert your servo motors into each row with the orange wire to the left (into P0 or P2).

Add the Servo Motor extension

Step 1

Servo motors can be controlled using the Pins blocks but it is easier to control them if you add the Servo Extension. In your MakeCode program, click on Extensions.

Step 2

Select the Servo extension (if it is not visible on the first page, search for Servo).

Test Out Some Code

Step 1

Before you build something, try out some simple code to familiarize yourself with how to control the motor. From the “Input” tab, select “on button A pressed.”

Step 2

Now select from the servos tab and pick a “continuos servos” block. Put two of these blocks into the Input tab and select one from P0 and the other from P2.

Step 3

Select a “pause” block from the “Basic” tab.

Step 4

Select a “Stop servo” block from the “Servos” tab and use two of them to stop the servo.

Step 5

Upload the program and test it out

Build Something!

Step 1

Robots come in many shapes and sizes. Build your own or pick one of the projects designed specifically for the Makey:bit: Walking Robot or Robot Buggy.
Follow the assembly instructions for the project you pick. 

Step 2

Once assembled, take a close look at the position of the motors in your robot. Notice that they are mirroring each other. Almost any robot design will have the two motors positioned as mirror images of each other. What does that mean for your code? You probably guessed it… forward for one motor means reverse for the other motor! Update your code and test it out.

Build Something!

Step 1

Now that we know how to control motors and LEDs on the micro:bit and the eyes, we can use Functions to streamline our code for commonly used commands. In this case, let’s create a command for the robot that we will call “goForward”. Start by clicking on the “Advanced” tab.

Step 2

Now select the “Functions” tab and click on “Make a Function.”

Call the function “goForward.”

Note: It is common naming convention for Functions to start with a lower case letter. This isn’t a requirement in MakeCode but we will use this convention.

Step 3

Now we can combine code within the Function block “goForward.” Let’s add a face that represents going forward. We can also make the colors of the eyes green to represent “goForward” and, of course, let’s make the motors turn in such a way that the robot goes forward.

Test and upload the code.

Step 4

Now try making a “goRight” and a “goLeft” block or even a “goBackwards” block.

What Is Happening Here?

What is a Servo Motor?

According to Wikipedia “A servomotor is a closed-loop servomechanism that uses position feedback to control its motion and final position. The input to its control is a signal (either analogue or digital) representing the position commanded for the output shaft.”

What does this mean? Essentially, a servo motor is a precise motor that is often used in robotics. There are two types of servo motors: continuous and 180. A continuous motor can spin forward and backward continuously and is most commonly used for wheels of a robot. A 180 motor can only move 180 degrees and is used when we want to have very precise control.

Servo motors come in many shapes and sizes and the most commonly used size for beginner maker projects are “micro-servo motors.” If the servo is marked “FS90R” it is a continuous servo. If you are unsure what kind of servo you have, look up online the part number marked on the servo to confirm before proceeding

About the Makey:bit

The Makey:bit Adventure Board is the perfect way to get started with microcontrollers. With this exclusive Maker Shed kit, you’ll be able to easily launch into the world of electronics and create amazing projects.

This all-in-one board includes everything you need to get started, including a built-in LED, buzzer, and various sensors. Plus, the Makey:bit is compatible with all kinds of additional modules, so you can easily expand your creativity.

So what are you waiting for? Get the Makey:bit Adventure Board today and start supercharging your microcontrollers!

Are you looking for a way to supercharge your microcontrollers? If so, then you need the Makey:bit Adventure Board! This exclusive Maker Shed product is packed with features that will take your microcontrollers to the next level. With the Makey:bit, you’ll be able to launch into the realm of microcontrollers and unleash their full potential. The Makey:bit is loaded with features that make it an essential tool for anyone looking to get the most out of their microcontrollers.

Start Here: Bring Makey Alive with a Beating Heart

less than 30 min

Ages 11-13

What Will You Make?

Make a simple “beating heart” animation using the grid of LED lights on the front of the micro:bit board.

What Will You Learn?

The Flashing Heart shows you how to write and upload your first program to the micro:bit using free, online Microsoft MakeCode software. It’s based on the tutorial on the micro:bit web site at https://makecode.microbit.org/ This version adds a few steps, so you can move along in your coding adventure quicker!

Prepare the Makey:bit

Step 1

Insert the batteries into the back of the Makey:bit. Make sure the batteries are facing the right in the correct direction.

Step 2

Now insert the micro:bit in the front holder, with the buttons facing out.

Step 3

Turn on the Makey:bit with the red on/off switch in the back.

Step 4

Extra! If this is a brand-new micro:bit, it should have a fun little pre-loaded program that which provides a guided tour of the micro:bit. Turn on the Makey:bit with the red on/off switch in the back and take a few minutes to follow the directions and play around with the board.

Write Your Code

Step 1

The micro:bit can be programmed in multiple programming languages including micro Python and the Arduino IDE, but the easiest way to program it is with Microsoft MakeCode. Go to https://makecode.microbit.org/ to get started.

Step 2

Open a new project on the micro:bit MakeCode website (https://makecode.microbit.org/). You’ll see a column of different categories of blocks.

Step 3

Click on Basic. When the menu of blocks in the Basic category opens, click on the “show LEDs” block and drag it into the workspace. This block lets you turn the micro:bit’s LEDs on and off. Click on the little boxes to draw a heart with lights.

Step 4

When you’re done, drag the “show leds” block inside the “forever” block that’s already in the workspace.

Upload the Program

Step 1

Insert the USB cable into the micro:bit, click the Download button, and follow the instructions to download the program to the board. The lights you selected on your board should light up.

Make the Heart Beat

Explaination

What if we want to make the heart look like it’ is beating? We can do that the same way cartoon animators make things look like they’re moving: by replacing the image with a slightly different one. If you switch them quickly enough, your brain thinks it’s watching an object moving or changing shape! In this case, we’ll go back and forth between two versions of the heart image.

Step 1

First, add another “show LEDs” block underneath the first. On the micro:bit simulation on the screen, you’ll see the heart drawing flash on and off.

Next, let’s draw a slightly different heart in the second “show LEDs” block.

Step 2

Use the “pause” block between the multiple “show LEDs” blocks to slow down the transition and animate the image.

Step 3

Let’s make it look like it is pulsing over and over. We do this by putting it inside a “forever” loop.

When the micro:bit simulation on the screen reloads, the image will start to pulse!

Step 4

Finally, don’t forget to download the program to see how it works on the actual micro:bit board.

What Is Next?

Explore Animation

Now that you have figured out how to animate a flashing heart, what else can you add to the makey:bit?

Can you design an animated animal or face? Here are some ideas https://microbit.org/projects/make-it-code-it/animated-animals/. Make your own and animate it.

Explore other blocks that control the LED screen. What does the “show string” block do? The “show arrow” block uses an onboard sensor. Which sensor do you think it is using?

Build some code using two different blocks not covered in this tutorial.

About the Makey:bit

The Makey:bit Adventure Board is the perfect way to get started with microcontrollers. With this exclusive Maker Shed kit, you’ll be able to easily launch into the world of electronics and create amazing projects.

This all-in-one board includes everything you need to get started, including a built-in LED, buzzer, and various sensors. Plus, the Makey:bit is compatible with all kinds of additional modules, so you can easily expand your creativity.

So what are you waiting for? Get the Makey:bit Adventure Board today and start supercharging your microcontrollers!

Are you looking for a way to supercharge your microcontrollers? If so, then you need the Makey:bit Adventure Board! This exclusive Maker Shed product is packed with features that will take your microcontrollers to the next level. With the Makey:bit, you’ll be able to launch into the realm of microcontrollers and unleash their full potential. The Makey:bit is loaded with features that make it an essential tool for anyone looking to get the most out of their microcontrollers.

Makey:bit Brand New Eyes!!

less than 30 min

ages 11-13

What Will You Make?

This project shows how to control the color of the Makey:bit’s eyes and write a program to randomly change the eye color every time you shake the Makey:bit + micro:bit.

What Will You Learn?

Learn how to control the Makey:bit eyes by learning about programmable, addressable LEDs controlled by the NeoPixel driver.

Learn how to install Extensions in MakeCode.

Learn how to use math blocks in MakeCode.

What are the Makey:bit eyes?

Neopixels

The eyes of the Makey:bit are NeoPixel-compatible Light Emitting Diodes (LED) that can be individually programmed. Each eye has a Red, Green and Blue (RGB) LED and the brightness and intensity of each color can be controlled through code. Multiple Neopixels can also be put together on a strip or grid and can be individually controlled based on the order they are on the strip (starting with 0 through however many NeoPixels we have).

Adding NeoPixel Extension

Step 1

Neopixels are not standard with every micro:bit so first step is to add the blocks needed to control them in MakeCode. In programming, blocks of code that are used for a specialized purpose are often called “drivers” or “libraries.” In MakeCode, we can add new drivers and libraries by going to a section called “Extensions.”

Step 2

Open your beating heart program in MakeCode. Click on the “Advanced” tab in the code blocks section.

Step 3

Scroll to the bottom of the blocks and click on “Extensions”

Step 4

On the top row there is a square for the Neopixel drivers, click on it.

Program the Eyes

Step 1

Now you should be back in the MakeCode programming environment and a new tab should be visible called “Neopixel”.

Step 2

First you have to tell the micro:bit that NeoPixels are connected to it. Click on the Neopixel tab and drag the “set strip…” block to the “on start” block. On the Makey:bit, the NeoPixels are connected to pin 16 so select P16 and since there are two eyes, select “2” LEDs.

Step 3

NeoPixels are very bright when on full (default) so it is recommended to use the “set brightness” block to set the brightness to roughly half (they can go from 0-255 so 100 is a good starting point).

Step 4

Now that the micro:bit knows that there are NeoPixels connected. Let’s turn on the colors. Use the “strip set pixel color…” block and put it inside the forever loop.

Remember, the NeoPixels start at 0 so even though there are two Neopixels, the first one (left) is “0” and the second one (right) is “1”.

Don’t forget to use the “show” block otherwise nothing will happen.

Step 5

Upload the program.

Random Color Generator

Step 1

Neopixels make colors by combining red, green and blue.

On the “more” menu of the Neopixels tab, there’s a block that lets us make our own colors by combining them ourselves.

In this block, 0 is “off” and 255 is maximum brightness. When all are at 255, the color looks white. When only one color is on, the color is that color… etc.

You can drag this block where the color name is currently showing and make your own colors by changing the values directly.

Step 2

If you want to explore how many colors the NeoPixels can make, you could do it manually but that would take a long time. Instead, let’s explore an alternative approach.

Step 3

Now is a good time to explore the “Math” blocks. Click on that tab and select the the “Random” block.

If you put in a random number between 0-255 into the value, now, every time the heart beats, a new random number and color will appear.

Upload the code and observe how the Makey:bit functions.

Sample Code

Link to MakeCode: https://makecode.microbit.org/_6k7dUThyPLo2

Note: In the sample code there’s an additional math step where we pick a random number between 1-25 and then multiply the number by 10… Can you guess why that was done?

What Is Happening Here?

Intro to Makey:bit

This is an introductory programming project for the Makey:bit that explains how to add extensions and program features of the Makey:bit.

This is also an introductory project to explore how colors are most commonly generated in most computer screens, through a combination of “RGB” (Red, Green and Blue) Lights. The Makey:bit eyes are RGB LEDs and the final code will generate thousands of different colors by changing the level of Red, Green or Blue in the eyes.

About the Makey:bit

The Makey:bit Adventure Board is the perfect way to get started with microcontrollers. With this exclusive Maker Shed kit, you’ll be able to easily launch into the world of electronics and create amazing projects.

This all-in-one board includes everything you need to get started, including a built-in LED, buzzer, and various sensors. Plus, the Makey:bit is compatible with all kinds of additional modules, so you can easily expand your creativity.

So what are you waiting for? Get the Makey:bit Adventure Board today and start supercharging your microcontrollers!

Are you looking for a way to supercharge your microcontrollers? If so, then you need the Makey:bit Adventure Board! This exclusive Maker Shed product is packed with features that will take your microcontrollers to the next level. With the Makey:bit, you’ll be able to launch into the realm of microcontrollers and unleash their full potential. The Makey:bit is loaded with features that make it an essential tool for anyone looking to get the most out of their microcontrollers.

Makey:bit Animatronic Face

About 3 hours

Ages 8+

What Will You Make?

Makey:bit controls this animatronic face. It can open and close its mouth, roll its eyes, and raise and lower its unibrow.

What Will You Learn?

You’ll learn to control servos with micro:bit and MakeCode.

Prepare Your Materials

Step 1

For the face, make or take a box with two flaps that meet at the middle. Turn it so one flap opens and closes from the bottom – this is the mouth. Tape the upper flap closed. This is where the eyes and unibrow will go.

Step 2

For a push rod, straighten a paperclip, leaving the bends at the ends to use as hooks.

Step 3

For the eyes, find or cut a cardboard tube a little shorter than the width of the box.

Step 4

For the arm (which holds up the eyes tube), cut a strip of cardboard just wide enough to fit inside the tube without rubbing. It should be long enough to fit at least halfway into the tube, with enough hanging outside for the arm.

Attach a Servo to the Box to Open the Mouth and Roll the Eyes

Step 1

Mark a spot for a servo on one side of the box, about an inch away from the front and even with the level of the eyes. Trace around the servo at that spot, and cut out a hole to hold it snugly. Insert the servo into the hole from the inside, so the cable is outside the box.

Step 2

Snap a servo horn onto the servo. Mark one arm (or a spot along the edge if you’re using the circle horn) to be your measuring point. It will point up when the mouth is closed.

Step 3

To calibrate the servo so it points the right way:

  1. Turn the horn to the right as far as it will go.

  2. The measuring spot should point directly to the right (the 3 o’clock position). If it doesn’t, take it off and re-attach it so it does.

  3. Remove the servo horn.

  4. If you are leaving out the eyes tube, hook the smaller end of the paperclip through a hole along the servo horn and go directly to Finish the Face from here.

Step 4

Cut out a circle of cardboard about ¼ inch bigger around than the cardboard tube.

Step 5

Tape the servo horn to the middle of the circle.

Step 6

Tape one end of the tube to the circle. Make sure the servo horn is facing out!

Step 7

Hook the smaller end of the paperclip through the cardboard circle. If you need to save space, you can trim it later to an egg shape, leaving an overhang where the paperclip is attached.

Insert the Arm

Step 1

Snap the eyes tube onto the servo with the measuring point facing up.

Step 2

Hold the tube straight across, and mark where the top and bottom of the tube would meet the box if it were long enough. Cut a slot for the cardboard strip between those marks.

Step 3

Insert the arm strip through the slot from the outside and into the eye tube.

Step 4

Bend the outside of the arm forward to hold it in place. If you need to remove or adjust the eye tube, gently pull the arm strip out of the box.

Finish the Face

Step 1

Make sure the measuring point on the servo horn is pointing up.

Step 2

To attach the loose hook on the paper clip to the mouth, poke a hole through it. You can also tape on an extra piece of corrugated cardboard with the channels running sideways and insert the hook into the channel that fits best. Test to make sure you can pull and push the mouth open and closed.

Step 3

Cut the holes for eyes, making sure they are even with the tube inside the box. Draw eyes on the tube with the mouth open and with it shut. Write “back” on the back of the tube so you can re-connect it correctly if you need to.

Add the Unibrow

Step 1

Use a straw or pipe cleaner (or both) to make a brow that bends in the middle. Attach one end to the face so it can pivot. If you’re using a pipe cleaner, you can poke a hole right in the cardboard and insert the end. With a straw, hold it one with a small screw or pin.

Step 2

The servo motor for the brow goes inside the box. The top of the servo motor sticks out the front of the face, above the eye. (Duh.) Trace and cut out a hole so just the top of the servo sticks out. Use plenty of tape to hold the servo motor in place.

Step 3

Tape the loose end of the brow to a servo horn. Wrap some masking tape around them to hold them together.

Step 4

Snap the horn onto the servo with the brow straight.

Connect the Makey:bit

Step 1

Insert the micro:bit into the Makey:bit.

Step 2

Stand the Makey:bit on top of the Animatronic Face box. Secure it on with some kind of attachment, tape, or glue, such as a strip of peel-and-stick Velcro or Legos.

Step 3

Cut a hole in the top of the box near the Makey:bit big enough for the ends of the servo motor cables to pass through.

Step 4

Pull the cable for the servo attached to the mouth and eyes out through the hole. Plug it into the Makey:bit using the pins marked Servo A (SRVA). This servo will be programmed using pin P0.

Step 5

Pull the cable for the brow through the hole the same way. Plug it into the Makey:bit using the pins marked Servo B (SRVB). This servo will be programmed using pin P2.

Troubleshooting

If your face is not moving correctly, try these tips:

  1. Tuck in loose wires.

  2. Bend the paperclip if needed to make the mouth open and close correctly.

  3. Make sure the paperclip doesn’t hit anything as it moves.

  4. Check that the eye tube has not detached from the servo.

Write the MakeCode Program

Sample Code

Sample Code: https://makecode.microbit.org/_U7fdKWMA2WLX 

This program will make the mouth open and close, the eye tube roll, and the unibrow scowl or look happy. To test out the code, it uses Button A to move the mouth and eyes, and Button B to move the unibrow. When it’s working, check out additional ideas to make your Animatronic Face seem more alive!

Remember, you may need to set your servos in the opposite direction of these instructions, depending on how you placed your servos in your model!

Step 1

On start, set both servos – P0 and P2 – to 90 degrees. This makes sure the mouth is closed and in the neutral position for the motors. (If the mouth is open too much, readjust your paperclip and/or your eyes tube.)

Step 2

To open the mouth and make the eyes roll up, make servo P0 turn to the left:

    1. Type in or use the slider to adjust the “set servo angle” block for P0 to about 10 degrees.

    2. Insert a pause of about one second (1000 milliseconds, or ms).

    3. Use another “set servo angle” block to set it back to 90.

    4. Place the blocks inside a repeat block set for as many times as you want the mouth to open and close.

    5. Place the entire stack inside an “on button A pressed” block so you can trigger the action.

Step 3

To make the unibrow point down, go back to the middle, and then point up, swing the servo at P2 in both directions:

    1. Type in or use the slider to adjust the “set servo angle” block for P2 to about 10 degrees.

    2. Insert a pause of about one second.

    3. Use another “set servo angle” block to set it back to 90. Add another pause.

    4. Use a third “set servo angle” block to move the servo to 170 degrees, the opposite direction. Add another pause.

    5. Use the last “set servo angle” block to set it back to 90.

What Is Next?

More Ideas

  1. Program the lights to flash or show images that match your animatronic face’s moods.

  2. Add Music blocks to make the mouth talk. Scroll down to the bottom of the Music block menu to find the “play sound” block. It includes sounds like “giggle” and “yawn.” Or use notes from the Tone section of the Music menu to create your own “tonal” language!

  3. Add “on sound” blocks from the Input menu to make the mouth “answer” with tones when it hears someone talk to it.

About the Makey:bit

The Makey:bit Adventure Board is the perfect way to get started with microcontrollers. With this exclusive Maker Shed kit, you’ll be able to easily launch into the world of electronics and create amazing projects.

This all-in-one board includes everything you need to get started, including a built-in LED, buzzer, and various sensors. Plus, the Makey:bit is compatible with all kinds of additional modules, so you can easily expand your creativity.

So what are you waiting for? Get the Makey:bit Adventure Board today and start supercharging your microcontrollers!

Are you looking for a way to supercharge your microcontrollers? If so, then you need the Makey:bit Adventure Board! This exclusive Maker Shed product is packed with features that will take your microcontrollers to the next level. With the Makey:bit, you’ll be able to launch into the realm of microcontrollers and unleash their full potential. The Makey:bit is loaded with features that make it an essential tool for anyone looking to get the most out of their microcontrollers.

FEEDBACK