How to Make a Game by Using a Microcontroller - Part 2

2023-08-16 RENESAS Blogs
MCU,RL78,RENESAS

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


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


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.

Here is the completed hardware.

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.



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.


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.

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


Supplement

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

  • +1 Like
  • Add to Favorites

Recommend

This document is provided by Sekorm Platform for VIP exclusive service. The copyright is owned by Sekorm. Without authorization, any medias, websites or individual are not allowed to reprint. When authorizing the reprint, the link of www.sekorm.com must be indicated.

Contact Us

Email: