Image
Taisei Kurokawa
Taisei Kurokawa
Application Engineer
Published: August 10, 2023

In the second installment of the "Let's Make a Game Using a Microcontroller!" series, we will create a falling block puzzle game using the RL78/G23 Fast Prototyping Board (FPB).

If you haven't yet prepared your development environment, please refer to the Start Developing with the RL78 - Essential for Microcomputer Beginners - Part 1 blog for guidance.

Image
Tetris Game with Using a Microcontroller

Hardware Design

I will introduce the components used in the hardware design.

  • RL78/G23 FPB
  • Micro USB Type-B
  • 5 x 7 blue dot matrix LED (MOA20UB019GJ) × 3
  • Tactile switch × 4
  • Resistors 1kΩ × 4, 390Ω × 21
  • Capacitor 0.33μF
  • Source type transistor array (M54564P)
  • Sink type transistor array (TD62083APG) × 3
  • Universal board for Arduino (AE-ARDUINO_UNI-G) × 2
  • Pin socket (FHU-1x42SG)
  • Pin header (PH-1x40SG)

I have implemented the following circuit on a universal board.

Image

Here is the completed hardware.

Image
Tetris Game Hardware Design
Image
Tetris Game Hardware Design with Arduino UNO

Using a universal board compatible with Arduino UNO is recommended. The board comes with an Arduino UNO connector, making wiring a breeze. I was able to create beautifully finished hardware.

Software Design

I used a code generation tool called Smart Configurator to set up the initial configuration for each peripheral function. By simply selecting the desired features, you can easily generate the code.

Here are the steps to use the Smart Configurator.

1. Click on the "Smart Configurator (Design Tool)" link indicated by the red box in the image below to launch the Smart Configurator.

Image
Smart Configurator Setup
Image
Smart Configurator Setup - Initial Settings

2. Select the tabs indicated by the red frame in the image below to make the initial settings for the clock, peripheral functions, etc.

3. Once you have finished configuring the settings, click on "Generate Code" to generate the code.

Image
Smart Configurator - Generate Code

For detailed instructions on how to use the Smart Configurator, please refer to the user guide provided below.

The Smart Configurator not only supports the initial setting but also generates the necessary functions for using those peripheral functions. For example, when using the Interval Timer feature of the Timer Array Unit, you can start the timer simply by calling the generated functions.

Image

Once the code generation is complete, let's create the falling block puzzle program. I created the program with reference to the YouTube video from Gamedokan, a game development channel.

The video was easy to understand and interesting, with programming while explaining the actual situation.

Please try creating it yourself while watching the video.

You can also download the program I created, which is located on the RL78 MCU Forum page of the Renesas Engineering Community site.

Supplement

By modifying the number in the image below, you can adjust the speed at which the blocks fall.

Image

Share this news on