When LEGO Meets Arduino: Desktop Table Tennis Ball Launcher

“With weak fingers and blurry eyes, neck pain, back pain, and fragile shoulders,” I believe every friend who has been sitting at a computer for a long time in one position has their own different “pain insights”.

Netizens have also thought of many ways to increase their activity levels. For example, this can help move the arms and shoulders.

When LEGO Meets Arduino: Desktop Table Tennis Ball Launcher

For example, reading this text can help move the neck (not asking you to turn your phone).

When LEGO Meets Arduino: Desktop Table Tennis Ball Launcher

These methods, to put it simply, are about appropriately increasing physical activity during work breaks. But when colleagues around you suddenly start shaking their heads or dancing, it can easily scare others.

So exercise needs to look like exercise; we still have to do some formal workouts. However, exercise cannot do without equipment and space; what if there is none in the office? As makers, we can’t help but brainstorm.

So we casually used LEGO again… to make a small device: desktop table tennis ball launcher.

When LEGO Meets Arduino: Desktop Table Tennis Ball Launcher

This device has the following advantages:

  1. Compact and easy to carry

  2. Requires little space, highly playable

  3. Exercises reaction speed (ball serving time is random), attention (ball speed is fast), logical analysis ability (judging the ball’s trajectory, landing point, rebound direction), physical coordination ability (being able to catch the ball)

  4. Appropriate amount of exercise (catching the ball and returning it or running with the ball—collecting balls—returning it)

  5. Accelerates blood circulation, improves brain oxygen supply

  6. Exercises hand-eye coordination, engages all muscle groups

Moreover, this device can be played by one person or two. We specifically added a remote control function to the launcher, so after you take your position with the racket, you can press the remote to start exercising, without having to first turn on the LEGO power and then hurriedly run back to catch the ball.

One person can play by pressing the remote; the program will randomly trigger the motor at intervals to continuously shoot balls.

When LEGO Meets Arduino: Desktop Table Tennis Ball Launcher

For two players… it’s not doubles; rather… one fills the balls while the other catches them. It doesn’t matter if you can’t play table tennis; you can use paper cups to catch them.

When LEGO Meets Arduino: Desktop Table Tennis Ball Launcher

After exercising, do you feel refreshed and your mind active? While creating the remote control function for the launcher, we used a new technical component:

LEGO infrared control

As usual, we used the most commonly used infrared kit available on the market:

When LEGO Meets Arduino: Desktop Table Tennis Ball Launcher

Infrared remote control module

To make LEGO listen to commands, we first need to make arduino understand infrared commands. The previous article compared smart appliances and traditional appliances and mentioned that infrared remote control requires both a transmitter (left in the image) and a receiver (right in the image) to work together.

The principle of infrared control is that the transmitter emits signals at a specific frequency, and the receiver receives and decodes them; the program triggers different feedback based on different decoding results. The control signals are sent by the infrared diode in a specific on-off pattern with different intervals, the receiver outputs a high level normally and outputs a low level when it receives a command:

When LEGO Meets Arduino: Desktop Table Tennis Ball Launcher

Infrared signal transmission schematic

The signal in the above image is actually a series of specific durations of infrared diode on and off; this infrared command is read by arduino as follows:

When LEGO Meets Arduino: Desktop Table Tennis Ball LauncherTime encoding

Such commands not only look complex but are also inconvenient to debug, so manufacturers usually translate these codes into 1010 binary before converting to 16 hexadecimal for display. The translation standards vary by manufacturer; according to the most commonly used NEC standard, 2.25ms waveform represents 1, 1.12ms waveform represents 0:

When LEGO Meets Arduino: Desktop Table Tennis Ball Launcher

NEC decoding standard

Let’s take a look at the infrared command we obtained earlier:

When LEGO Meets Arduino: Desktop Table Tennis Ball Launcher

Infrared command source code

600+550=1150μs, corresponds to 0; 550+550+600+550=2250μs, corresponds to 1; thus, the above code translates to 01110.

Now let’s look at the NEC infrared command encoding method:

When LEGO Meets Arduino: Desktop Table Tennis Ball Launcher

NEC infrared encoding format

Guidance code + User code + Data code + End code (no signal),” the guidance code and data code are transmitted twice by default, once in the forward direction and once in the reverse direction for the receiver’s calibration (as shown in Figure 10, the same key corresponds to three occurrences with a local 50μs difference). Knowing the pattern, we can easily extract the commands we need. We can convert the control command in binary to 16 hexadecimal:

When LEGO Meets Arduino: Desktop Table Tennis Ball Launcher

NEC standard decoding (where FFFFFFFF is the repeat code)

Isn’t it suddenly clear? So we can easily obtain the correspondence between the buttons on the remote and the commands:

When LEGO Meets Arduino: Desktop Table Tennis Ball Launcher

Remote control command correspondence chart

At this point, we have completed the cracking of the remote control commands; the remaining tasks are simple. We only need to set different commands to trigger operations in the program. For this case, that means random triggering or immediate triggering. For random triggering, the program will generate a random number from 1~5 and trigger the launch program after a corresponding delay.

So the process can be summarized as:Remote control emits command—Receiver receives and decodes—Triggers corresponding operation; this is the principle of infrared remote control.This process can be seen everywhere, like changing channels or adjusting the volume on a TV; we just applied it to LEGO.

In addition to controlling LEGO to launch balls, controlling relays to switch appliances is a straightforward application. We can also combine Arduino‘s infrared diode to make a transmitter to control other devices. For example, we can decode the most commonly used remote control commands for TVs and air conditioners at home and map them to rarely used buttons on one remote. By writing a small program, if the receiver receives control signals from these rarely used buttons, Arduino can control the infrared transmitter to send the corresponding original remote control commands, thereby concentrating multiple remote functions into one remote. This is the principle behind various products on the market that combine phone audio jacks or smart infrared boxes. If you enjoy hands-on projects, you might as well try it out; combined with the IoT concept from the previous article, you can control your home appliances remotely, making the realization of smart homes a tangible possibility.

What are you waiting for? Let’s be makers together.

To be continued.

For previous articles in this series, click to read:

  1. “When LEGO Meets Arduino: How to Control LEGO Components Externally”

  2. “When LEGO Meets Arduino: LEGO PM2.5 Detector”

  3. “When LEGO Meets Arduino: LEGO Calls You to Dinner~”

—————————————————————————————————

Scan to add “Learning Community”

Join the teacher discussion group of the Technology Learning Community

When LEGO Meets Arduino: Desktop Table Tennis Ball Launcher

Leave a Comment

×