Image
Sota Shinohara
Application Engineer
Published: May 29, 2023

Here's a procedure that even beginners can use to easily create a game using a microcontroller.

The RL78 microcontroller has a cheap and easy-to-use development environment available. For this tutorial, we used the RL78/G23 Fast Prototyping Board (FPB) to create a mole-catching game.

First, let me explain the mole-catching game. The game randomly lights up the segments of a 7-segment LED at fixed time intervals, and the player has to press the button at the moment when the decimal point is lit up. If the player manages to stop the decimal point, then they have successfully caught the mole (as shown in Figure 1).

To create the mole-catching game, please obtain the following necessary components from your favorite online shopping site or other sources.

• 1-digit 7-segment LED
• LEDs (blue, red)
• Tactile switch
• 120Ω resistor
• Sink-type transistor array
• Jumper wires
• Micro USB Type-B cable
• FPB (RL78/G23 64-pin)

## Integrated Development Environment (IDE)

Next, let's prepare the development tools. Install the development tools while referring to the Start Developing with the RL78 - Essential for Microcomputer Beginners - Part 1 blog. For reference, I chose CS+ which is easy to understand even for beginners.

## Peripheral Function

Let me briefly introduce the peripheral functions of the RL78/G23 that were used in programming the mole-catching game.

1. Port function: Used to control the 7-segment LED display.
2. Timer Array Unit (TAU): Generates interrupts at regular intervals to adjust the display time of the 7-segment LED.
3. True Random Number Generator (TRNG): Used to generate random patterns of LED display.

Reference: RL78/G23 Product Information Page

## Creation Process

Let's create the game by following the steps below.

1. Download the code that has been created using C language from the following URL (available in Japanese only).
Code: Let's Make a Game Using a Microcontroller - Part 1: Sample Programs and More - Renesas Community
2. We will wire the circuit according to the circuit diagram shown in Figure 2 and demonstrated with the boards in Figure 3 and Figure 4.

In this game's specifications, the blue LED lights up when the game is successful, and the red LED lights up when the game is lost.

3. Connect jumper wires to the FPB as shown in Figure 5 and Figure 6.
Refer to Pages 16-18 of the "RL78/G23-64p Fast Prototyping Board User's Manual" for the terminal layout of the FPB.
4. Connect the USB cable to both the PC and the microcontroller as shown in Figure 7.
5. Debug the code using CS+, see Figure 8 for reference.