[No.13] Make a Glowing Beach Ball!

Programming and Making

In the last lesson, you used the angle values from the "three-axis gyro and three-axis acceleration sensor module." This time, you'll use its acceleration values to make a mysterious glowing beach ball. You'll use a fun expansion part called the "Space Ball"! The Space Ball is a special beach ball that can hold a SPACEBLOCK inside.

Elementary School ~ Intermed. 55 min

What You Need & Getting Ready

Top row, from left: SPACEBLOCK Standard Package, three-axis gyro and three-axis acceleration sensor, 8×8 RGB LED matrix panel. Bottom row, from left: jumper wires, Space Ball

Connect the Expansion Parts to SPACEBLOCK

The connections are exactly the same as in the previous lesson. For the details, see the previous lesson, "Tilt It, Move It, Control It!! – Three-Axis Gyro and Three-Axis Acceleration Sensor."
The whole setup

What Is Acceleration on the Three-Axis Gyro Sensor?

A three-axis gyro sensor can measure tilt angles and acceleration. This time we'll use the acceleration values. How to use tilt angles is explained in detail in the previous lesson, so take a look.

The three axes of acceleration

Acceleration tells you how fast something is moving. The three-axis gyro has an X-axis, a Y-axis and a Z-axis, and it measures which way the board moved along each axis as acceleration X, acceleration Y and acceleration Z.

Acceleration X, Y and Z values

Range of acceleration values

When the movement is slow, the number is close to 0. When it's fast, the number gets close to 100. Each axis has a plus direction and a minus direction.

Check the Acceleration Values

To use the three-axis gyro sensor's acceleration in a program, use the [Read acceleration (X) from gyro (PB1, PB3)] block in the "Input" category. Combine it with [Repeat] and [Show number (0)] to see the values in the console.
Programs use special gyro blocks

Let's actually check the acceleration values in the console.

Run this program and the acceleration values keep appearing in the console

Run the program and move the SPACEBLOCK with the three-axis gyro sensor attached. You'll see the values change depending on the direction and speed of the movement. Check how each of "X," "Y," "Z" and "absolute value" relates to the movement. Note that "absolute value" uses the highest of the absolute values of the X, Y and Z acceleration.

Change the LED Panel Display with Acceleration!

Now it's finally time to make the glowing ball. Blowing up the Space Ball is the fun part saved for last. First, let's program the SPACEBLOCK. The ball keeps moving in all directions, so we'll make the way it lights up change with the speed of the movement, no matter which way it moves. Let's build the program using the "absolute value" of the acceleration.

Create a variable

Create a new variable and name it "acceleration."

Create the variable "acceleration"

Combine the [Repeat] block and the [Number set (variable name) to ( )] block, and set the gyro's acceleration "absolute value" into the variable "acceleration."


Run this program and the acceleration values keep appearing in the console

Split the program by conditions

Next, make the program that switches the LED display. Use the [if ( ) then … else …] block and the [(0) (=) (0)] block to show the LED panel in 4 different ways depending on the acceleration value.

Branch into 4 cases depending on the acceleration "absolute value"

Choose what the LED panel shows

Put LED panel blocks inside the [if ( ) then … else …] block, and the program is finished as shown in the next picture.

A program that changes the LED panel display based on the acceleration "absolute value"

The program is done

That's it for the program. The LED display changes like this depending on how fast you move it.

Running the program and moving it at different speeds

Let's watch a video of the program running.

QR code for project

Put It in the Space Ball!

Now it's finally time to use the Space Ball! Blow some air into the Space Ball, and once it's partly inflated, put the SPACEBLOCK into the tube-shaped space in the middle, then blow it up all the way.

Before putting it in the Space Ball, stack the SPACEBLOCK, battery box and LED panel and tape them together so they stay in one piece. To keep sharp corners from making holes in the ball, it's a good idea to wrap everything in bubble wrap. Don't forget to turn the battery box switch ON first!

Put the SPACEBLOCK into the tube in the middle of the beach ball, then inflate it more

The air pressure holds the SPACEBLOCK in place.

It lit up when we moved it!
Throw it, roll it, move it in all kinds of ways and enjoy the changing light!
It lights up in 3 different ways depending on how you move it

Let's watch the video.

From a different angle... It looks beautiful when it rolls!

Like in this example, you can just enjoy making it glow, or you could carry it very carefully and play a game where you lose if it lights up. You can change how much movement makes it glow as much as you like by adjusting the program. Think up lots of different ways to play!

Finally, here's a video from the official SPACEBLOCK page.
A workshop where you make glowing balls like this looks like so much fun!!

By the way, in this video the program seems to change color every time the ball is shaken. There's also a block that checks whether it was shaken, which is handy for this. Keep changing and remixing your program to match the way you play!!