Today I would like to share a project to create a simple logical game "Columns". For this we need:
- One of the most affordable and affordable SPI displays,
- Arduino Nano,
- TFT-shield for Arduino Nano (with which we will combine the individual components into a single unit).
Brief description of TFT shield:
- The size of the board is 64x49 mm,
- 30-pin connector for connecting Arduino Nano,
- 14-pin connector for connecting a TFT display 320x240 with an SPI interface (including a touch screen),
- Connector for microSD card,
- Connector for the Bluetooth module (HC-06),
- 20-pin connector for camera OV7670 (as well as others),
- Mini USB connector, as well as a separate 2-pin connector for power supply 5V.
The game itself is very famous, so I will not dwell on the description of its rules. And talk about management. Because In this device there are no mechanical buttons we will use the touch screen of the display itself. The boundaries of the screen areas and their corresponding functions are shown in the following figure.
Nothing complicated. And so, let's get started.
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Assembly
Assembling boards is very simple. But care must be taken to read the contact designations before installation.First you need to install the Arduino Nano board as shown in the photo. After that, a display is connected, which can be connected both on one side of the board (photos from 1 to 6) and on the other (photos from 7 and other). After that, you can connect the power with a mini USB cable.The following are photos.
I chose the assembly with rack mounts, because This is a more compact design and is more comfortable to hold in your hand. Please note that the mounting holes are designed for a 2.8 "diagonal display.
After assembly, you can proceed to the download of sketches, but before these do not forget to install the necessary library for working with the TFT shield. The library is located on the link: https://github.com/YATFT/YATFT.
Before going to the sketch of the game itself, I would like to show you the board's capabilities in drawing text and graphics, as well as processing the touch screen.
Step 2: Demo 1. Graphics and Text.
This chapter provides an example of working with text, graphics, and a touch screen. This sketch uses fonts from the Adafruit library.
It is recommended for convenience that you first program the Arduino Nano board separately and then assemble the device (but you can also program the board as part of the device). Visually drawing elements on the screen is faster than if the screen were connected to Arduino Nano directly through the SPI.
Step 3: Demo 2. Touchscreen.
The following sketch shows how to work with the touch screen. Since the touch screen is resistive, it is more convenient to work with it using the stylus.
Using these two sketches as an example, you can already develop your own projects with graphics, text and a touch screen.
Step 4: Demo 3. Logic Game "Columns".
And finally, we come to the most important sketch - the logical game "Columns". Control, as I said, is done by clicking on the screen area (it is even more convenient than the mechanical buttons at the bottom of the screen). And due to the fact that there are several display sizes: 2.4 ", 2.8", 3.2 "(all software compatible), playing on a display with a diagonal of 3.2" is much more pleasant than at 2.4 ".
Step 5: Demo Video
At the end I added a demo video.
I hope you enjoyed my project. In the future, I plan to post a new project and show new features using this device. Thanks for attention!
Participated in the