What Will You Make?
It’s time to play! Use Makey:bit as a controller for your games, to connect the real world with the digital world.
Pressing the buttons will turn on Makey’s LEDs, and you will use these to catch all the tools you can, to earn points, and increase the difficulty.
What Will You Learn?
We will use Scratch block programming to create a fun game, using variables, sounds, sensors, and operations. We will program our Makey:Bit, to interact with the NeoPixels in Makey’s eyes.
Grab your materials...let's get coding!
Our code is divided into 2 parts:
1) The neopixels with Makey:Bit
2) The game with Scratch
Neopixels + Makey:Bit
We are going to go to the Makey-Bit-Projects project repository and download it, clicking on the green “code” button, we select the Zip format. When it finishes downloading, we open the “Makey-bit-scratch-gamer” folder where we have the complete code but divided into parts.
If you are new to the platform, the part on the left is our simulator, the middle part is the blocks menu, and the part on the right is our work table. In the upper part, we can change the programming language and the project configuration and in the lower part we have the section to download and save our program
Tip: The project is now ready to work with neopixels, but if you want to use it in another project you need to download its extension, go to Tool –> Extensions –> NeoPixel.
We have two blocks of blue color, let’s start with “on start”, we are going to place inside our block “set strip” to NeoPixel on pin 16 with 2 leds as RGB (GRB format)” with this block, we specify that we have two NeoPixels on pin 16. Next, we drag the “strip clear” block, Then we put the “strip show” block
We go to the blue “forever” block, we drag inside the first if “if button A+ B is pressed or button a is pressed or button b is pressed then”, inside the condition we place our second if “if button A+ B is pressed then” and in the first else we place the “if button A is pressed then” and in the last else we place the “strip clear” block.
What it’s doing is checking if we’re clicking any buttons, then checking which button we’re pressing to put the color on the neopixels and if not we turn off the leds.
To bring the code to our Makey:bit we click on the three dots next to the “download” button, select “connect device”, follow the steps and download it.
It’s time to test our code, pressing the microbit buttons and we see the neopixels change color.
Great we are already halfway through the project, now we will work on the scratch game Scratch
Scratch + Makey:Bit
We go to the Makey:bit Scratch Creator project, we click on “View inside” to start editing it.
On the left, we have our block menu, in the middle our artboard and on the right, we can test our project.
On the right side, we select the “Button2” now in the work area we are going to place our purple block “change background to transparent” and the purple block “hide” under the block “when clicking on this object”
After the block “when the background changes to instructions”, we put next the purple “hide” block. We continue with the block “when the background changes to home” we put the purple block “show” next.
Perfect now we select the “1-1” tool, we see the 3 yellow blocks of our main logic and the other blocks that we will need.
Below the yellow “when background changes to home” block, we are going to place the purple “hide” block. Then the “when the background changes to instructions” block, and we put the purple “hide” block.
Now the last yellow block “when the background changes to transparent”, we put next the purple blocks of “show” and “change costume to 1”.
Next we put our blue “set Y to 210” block.
Take the orange “forever” block that has a condition that only one tool per color appears on the screen. We place inside the condition the blue “turn -.1 degrees” block which also has a y-change block, which changes the speed taking into account the current points.
We place after the block “change y in – if touching the color-” and then we put our block “if position in Y < -170 then”.
What we are doing is that when it touches the corresponding color of Makey’s eyes, it changes our costume and gives us a point, but if on the contrary, it touches the ground, it takes away points and disappears.
We are going to add a sound when you touch the tools and earn points, we go to the sounds section, here we can import one or create it, remember to check the sound block in the code to specify the name of the sound and it works perfectly.
Let’s go to the last step and a very important one, adjust the colors that Scratch detects to earn points. We click on the green flag to start the game, we click on the hand with Makey:bit, the camera is activated. Now turn on Makey’s leds and place him in front of the camera, let’s start with the yellow color in the neo pixels, then in the work section and click on “touching color” we section the pointer, and select the color of the NeoPixels outline , also to have a better result the environment has to have little light.
Tip: To activate the camera, you must accept scratch permissions, we just click on the padlock on the left of the URL.
Perfect it’s time to play and have fun, show it to your friends and have fun with Makey:bit!
What Is Happening Here?
We are using a visual programming language to create a video game with Scratch, and programming Makey:bit with Make Code.
What Is Next?
It’s time to be creative in programming use different block objects or game dynamics. Then you can use the sensors that this board has like the microphone, accelerometer, and among others, to combine Makey:Bit with Scratch.
You can also find more information:
How to use Microbit with Scratch?: https://scratch.mit.edu/microbit
What is MakeCode and how to use it?: https://www.microsoft.com/es-es/makecode
MoonMakers — led by Camila and Diego Luna — are a community of creators passionate about knowledge. A Makerspace, an open space with different digital manufacturing machines. And a YouTube channel where we promote science, technology and the maker movement.
MoonMakers have collaborated with companies such as: Sesame Street, Make Community and in Mexico with Educational Television and Fundación Televisa, creating educational content.
We have given workshops throughout the Mexican Republic with: Talent Land, Secretary of Education in Jalisco, Conacyt, Centro Cultural España.