Let’s show you how easy it is to make a program in Scratch 3.0 and how to control it with your fingers using a Makey Makey.
In issue 019, we showed you how to interface your Scratch 3.0 digital projects with the physical world using the micro:bit. This month we'll look at connecting the world to your computer using the Makey Makey Invention Kit.
If you haven’t used Scratch before, Scratch is a fantastic way to teach children as young as 8 how to code. The intuitive coding system can be used online or offline on a desktop computer or tablet, and uses colourful coding blocks that kids simply drag-and-drop to create a program.
With the January 2019 release of Scratch 3.0, kids can now combine the magic of the digital world and the physical world. Scratch can connect to the computer’s camera, a Makey Makey, micro:bit, LEGO Mindstorms EV3, the LEGO WeDo 2.0, and more.
Read on to learn about the cool Makey Makey, how easy it is to make a program in Scratch 3.0, and how they can both work together for fun digital projects.
MAKEY MAKEY OVERVIEW
The Makey Makey is a fun and easy-to-use piece of hardware that interfaces with your computer by USB and behaves similarly to a keyboard and mouse. (‘Ma-Key’ is a play on words for ‘Make’ and ‘Key’).
The Makey Makey magic is how it allows you to turn everyday objects into computer keys. This includes many metallic and organic objects, such as fruit, vegetables, play dough, tinfoil, graphite pencils, liquids, etc. They just need to be conductive.
There are plenty of examples online on how versatile the Makey Makey is, and what objects you can use. Using Bananas to control a musical piano, joystick with metal bottle tops, even using the letters from alphabet soup are just some examples. With the use of alligator cables and short wires, it makes it easy to connect to everyday objects.
The Makey Makey is great learning product for kids to tech creativity as well as electronics fundamentals. Thanks to Scatch 3.0, kids can also learn how to code at the same time.
Let’s give you a run-down of what makes up this clever little Makey Makey circuit board that measures just 90 x 50mm.
ARROW BUTTONS: Simulates the Up, Down, Left and Right keys on your keyboard.
SPACE BAR: Simulates the Space Bar of your keyboard.
MOUSE LEFT CLICK: Just like pressing the left button on your mouse.
LEDs: Surface mounted LEDs on the board light up when the associated key is being triggered.
EARTH/GROUND RAIL: This earth rail completes the electronic circuit from any of the inputs. Your circuit must have at least one connection to this earth rail.
EXPANSION: When you have mastered the Makey Makey using the Alligator clips, you can expand it with connections to other hardware. The top expansion port provides a 5V output when a keyboard or mouse key is being triggered to activate real-world objects. A relay, for example.
USB: This Mini-B USB port provides power to the Makey Makey and also sends data to your computer. Connect one end of the supplied USB cable to this USB socket and the other end of the cable to a computer. Advanced users can also use this port to program the Makey Makey, remapping the keys, etc.
ARROW & MOUSE EXPANSION INPUTS: These inputs simulate the up, down, left, right arrow keys, and the left and right buttons on your mouse.
W, A, S, D, F, G EXPANSION INPUTS: These inputs simulate the W, A, S, D, F, G keys on your keyboard.
MICROCONTROLLER: The brains of the operation, based upon the Arduino IDE.
ALLIGATOR CLIP HOLES: Each pair of holes are designed for you to easily connect a lead with Alligator clips. You can connect the clip from either side of the board.
Important note: The guide above refers to the Makey Makey board that has ‘v1.4c’ printed under the logo on the back side. There are other Makey Makey designs with a slightly different pinouts. In general, they all work the same way.
You can purchase a Makey Makey from our friends at Altronics and Core Electronics.
To learn more about the Makey Makey visit: https://makeymakey.com
SCRATCH 3.0 OVERVIEW
Scratch 3.0 was released at the start of 2019 by the brilliant minds at MIT. It is free to use, and can be used directly on the Scratch website https://scratch.mit.edu, or downloaded to a desktop computer for use when the internet is not available. Scratch 3.0 is also tablet-friendly, so young kids can use their fingers on the touchscreen instead of having to guide a computer mouse.
Programming using Scratch is very easy. It uses colour-coded blocks that kids simply drag-and-drop on the screen. The blocks snap together like a jigsaw puzzle to create a set of instructions, also referred to as a script.
We’ve shown you a small script in the image above. Can you work out what it does?
ANSWER: Press the space bar to start the program. The cat sprite will go to the middle of the stage (position 0, 0) and point towards the right of the stage (90°). We then start a loop that repeats until the cat sprite touches your mouse pointer. The cat will point and move a random number of steps towards your mouse pointer as you move your mouse around. Once the cat touches your mouse pointer the program stops looping and makes a Meow sound.
Many Scratch programs use a Sprite graphic, like our orange cat. There are hundreds of pre-designed Sprites to choose from, or you can design your own using the editor. Some Sprites have Costumes that you can toggle between to show movement or similar animations.
To get your Sprite to perform something, you simply drag the Code blocks to the Script area and use an Event block to start your script. There are blocks designed to move or change the appearance of the Sprite or background, and blocks to make sounds or to show text on the screen. There are even blocks for doing mathematics and to manage data variables.
There is a lot more to do than what you see on the default Scratch interface. By pressing the blue coloured Add Extension button at the bottom left, you can add much more functionality. This is where we find the Makey Makey extension, which we will explain below.
There are plenty of tutorials within the Scratch interface to learn more, and the Scratch community is also a great place for inspiration.
If you are familiar with Scratch 2.0 but want to know about all of the new features in Scratch 3.0, read our ‘Scratch 3.0: We Have Lift Off’ article in Issue 18.
HOW TO CONNECT A MAKEY MAKEY TO SCRATCH 3.0
Connecting our Makey Makey to our Scratch 3.0 digital world is very easy. The Makey Makey behaves very similar to a computer keyboard and mouse, so it’s virtually plug-and-play. There’s is no need to install any additional software or plug-ins like we needed to do with the micro:bit in Issue 019.
STEP 1: PLUG IN THE USB
Your Makey Makey is supplied with a red USB lead. Plug the smaller USB plug into the Makey Makey and the larger USB plug into your computer. A red LED should illuminate on the Makey Makey board to indicate that the connection is successful.
STEP 2: CLOSE ANY POP-UPS
Your computer may display pop-up notifications on the screen asking you to install drivers or to complete another setup. Simply ignore, cancel or close these pop-up windows. No action is required.
STEP 3: GROUND YOURSELF
With one hand hold the Makey Makey Earth rail.
STEP 4: HIT SPACE
With the other hand touch the SPACE pad on the Makey Makey. You should notice the LED light up above that Space pad. This works just like the space key on your keyboard, so you could open a text editor and see the cursor move a space each time you press this key.
Well done, you have just interfaced the Makey Makey with your computer. Now to interface the Makey Makey with Scratch 3.0.
ADD THE MAKEY MAKEY EXTENSION TO SCRATCH
The code blocks for Makey Makey are not visible on the default Scratch 3.0 editor. You need to add this Makey Makey extension by following these steps:
Step 1. Press the ‘Add Extension’ icon in the lower left corner of the Scratch screen.
Step 2. Select the Makey Makey
You should now see two new code block appear at the bottom of the Blocks list. These two blocks are called Hat Blocks, which we will explain in further detail.
WHEN () KEY PRESSED
Use this Hat Event Block in your Scratch program to activate the script when an arrow key, w, a, s, d, f, g or the space key is pressed on the Makey Makey.
WHEN () PRESSED IN ORDER
Use this Hat Event Block in your Scratch script to start the script when the chosen keys are pressed in that specific order. They are:
- left up right
- right up left
- left right
- right left
- up down
- down up
- up right down left
- up left down right
- up up down down left left right right.
CONTROLLING SCRATCH WITH MAKEY MAKEY
There are so many ways to interface your Makey Makey with Scratch. As mentioned in our introduction, you can attach almost any conductive object to the Makey Makey circuit, from fruit to objects wrapped in tin foil.
A popular Makey Makey project found online is a piano that uses bananas as the piano keys. Using Bananas is brilliant to demonstrate the Makey Makey and is a lot of fun, however, by their nature, the bananas perish after a few days. They can be costly too depending on the season.
With our project, you can keep your bananas in the lunch box because we’re going to use what’s in your pencil case... a pencil! The graphite in the common school pencil is conductive, so we can make our piano keys using pencil markings on paper.
Over the next three pages, we will show you how to prepare the pencil drawn piano, connect it to the Makey Makey, and how to code Scratch 3.0 to make the musical notes that match the piano keys.
PENCIL DRAWN PIANO
We have prepared a piano template that you can download from the Resources section of our website and print out on your home printer.
Common 80gsm paper will work fine, but if you have a thicker paper (e.g. 120gsm) then that will help make the piano stay flat on the table. An alternative is to glue the 80gsm paper to thicker card.
You then need to fill in all of the piano keys and Earth key with a pencil. An HB pencil will work, but you MUST press hard or do a few thick layers to ensure the pencil lines are conductive. If you have a 2B, 3B or higher grade pencil, then use that instead of the HB.
Make sure you draw all the way to the edges of the page where the Alligator clips will connect.
Open a Scratch editor at https://scratch.mit.edu and add the Makey Makey extensions we discussed on the above.
PREPARE PIANO SOUNDS
We next need to tell our Scratch program what sounds in its large library of sound effects that we plan to play. To do this, click on the Sounds Tab. This Sounds area is where we will add in the C, D, E, F, and G piano key sounds into our program, along with a clapping sound effect.
First, search for the D piano sound by searching for "D piano". Select that ‘D Piano’ note to add it to your sounds library. Repeat this process for the C, E, F and G keys. Finally, search and add the sound for “Clapping”.
CODE THE PIANO
Click the Code tab so we can start adding code blocks to our script area
Drag and drop all of the code blocks to match what we show here. Make sure you match the piano sound with the chosen button. For example, make sure the ‘F Piano’ sound plays when the ‘up arrow’ key is pressed.
With the code all ready we can now move onto the final step of assembling the Makey Makey piano.
ASSEMBLING THE MAKEY MAKEY PIANO
You should now have your pencil drawn piano ready and the Scratch script on your computer prepared. We can now wire up our Makey Makey to the piano.
Grab your Makey Makey, USB cable and six Alligator clip leads.
Follow the wiring diagram we show below to run wires from the Makey Makey to the piano. Make sure you match the keys on the Makey Makey to the correct pencil piano key on the piano. For example, make sure the down arrow on the Makey Makey goes to the D key on the piano.
Don't forget to connect an Alligator lead from the Earth on the Makey Makey to the Earth on the bottom left corner of our piano.
Plug in the USB lead from your Makey Makey to your computer. If any pop-up windows appear you can close or ignore them.
You are now ready to test your piano.
TIME TO TEST
To play your piano you need to put one finger on the Earth pencil pad on your piano, and use your other hand to play the piano keys.
When you touch one of the piano keys you should see a green light on the corresponding key on the Makey Makey. You should also hear a sound play on your computer speakers. If you don't, refer to our troubleshooting guide below.
If you do hear a piano sound you can try playing the following keys in sequence:
C - D - E - F - G - F - E - D - C
If you play the notes F, E, D, C in a row correctly you will activate the sequence Event Block in our Scratch code. You should hear the sound of an audience clapping.
Nice work! You’ve done it!
If you DON'T hear a piano sound on your computer and you DON'T see a green LED light up on the Makey Makey then check your wiring. Make sure your pencil drawing is thick and ensure the Alligator clips contact the pencil drawing on the piano.
If you DON'T hear a piano sound on your computer but you DO see a green LED light up on the Makey Makey then check that your computer volume is turned up. If the volume is up, then make sure the Scratch script matches the one shown you above.
WHERE TO FROM HERE?
There are many way to expand on what we have done here. You could add the A and B piano notes by using the expansion sockets underneath the Makey Makey board. You can get A lligator clip to bare wire leads from Altronics and Jaycar to help with this.
Our Scratch project used traditional Piano sounds, but you could swap those out for the electric piano, saxaphone, trombone, trumpet, guitar and more.
You could super-size your piano by making it into a floor mounted piano. Glue large sheets of tin foil to cardboard to make piano keys. How cool would that be?!