Series: Using the GT-SP Touch Panel TFT Display with Arduino

Creating an Intuitive UI with an Ultrasonic Sensor: Switching GT-SP Images Based on Distance

Creating an Intuitive UI with an Ultrasonic Sensor: Switching GT-SP Images Based on Distance

DownloadDownload sample project & program (for GT Design Studio & Arduino)

Hello everyone, I’m @kissaten, a beginner in electronics. In this series, I’m explaining the process of connecting a 7-inch touch display (GT-SP series “GTWV070S3A00P”) to an Arduino and working on various projects.

This time, we will use a standard ultrasonic sensor to measure the distance to an object and create an intuitive UI that switches the GT-SP screen based on that distance. By incorporating a mechanism where graphics change in stages according to the distance, rather than just displaying fluctuating numbers, you can build a more practical interface.

 

Overview of This Project

In this project, we will create a mechanism that switches the image object on the screen in three stages depending on the distance when a hand is held in front of the sensor. Since the screen responds to the movement of a hand moving closer or further away, it can be utilized for applications that provide visual feedback on the operation status without physical contact.

Ultrasonic Sensor Wiring

The ultrasonic sensor has 4 pins. We will connect these to the Arduino using jumper wires. The wiring is as follows:

  • VCC pin: To Arduino 5V
  • GND pin: To Arduino GND
  • Trig pin: To Arduino pin 8
  • Echo pin: To Arduino pin 9

First, we will organize the wiring on a breadboard to verify the operation.

Picture by [Fritzing (CC BY-SA)]

Screen Creation in GT Design Studio

Open GT Design Studio and place an image object. Set this object No. to “0”.
Then, register 3 images corresponding to the distance in the “Image” property.

  • Image0: Far (25cm or more)
  • Image1: Medium (12cm to less than 25cm)
  • Image2: Near (less than 12cm)

Program to Write to Arduino

The sensor calculates the distance, assigns a numerical value of 0, 1, or 2 based on the result, and sends it to the GT-SP image object. The key point here is that the program is designed to send a command only when the value changes, which reduces the communication load on the display side.
If you actually open the Serial Monitor in the Arduino IDE, you can confirm that data is transmitted only at the moment the distance evaluation changes. Incorporating such minor optimizations leads to stable operation of the entire system.

DownloadDownload sample project & program (for GT Design Studio & Arduino)

 

Conclusion

Once you write the program and hold your hand over the sensor, the screen graphics will switch in real-time according to the distance to the object. By incorporating such visual changes rather than simply displaying numerical values as text, you can build a user interface that is intuitive and easy for anyone to understand.
Please try registering images suited to your own applications and utilize them for your original device development.

Series: Using the GT-SP Touch Panel TFT Display with Arduino

Series: Using the GT-SP Touch Panel TFT Display with Arduino