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

Controlling the GT-SP Analog Meter Using a Potentiometer

Controlling the GT-SP Analog Meter Using a Potentiometer

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.

In this experiment, we will use an Arduino and a potentiometer to control the analog meter on the GT-SP display. By reflecting the values obtained from the potentiometer in real time on the GT-SP, we can achieve simple and effective data visualization.

Introduction to the Analog Meter Tool

GT Design Studio comes equipped with an analog meter tool. By clicking on the icon labeled “AMT” in the toolbar, you can switch to the analog meter drawing mode.

Next, adjust the width and height to set the display area. This process is the same as when drawing button objects and other elements you’ve used before. When drawn in a square area, the default analog meter will be displayed. If it’s not a square, the design will be trimmed accordingly.

You can also modify properties such as the size of the needle, the red-highlighted range, and the maximum value. These features will be introduced in the next section.

Creating a Screen in GT Design Studio

We will now place the elements in GT Design Studio.
Click the ‘AMT’ button on the toolbar and draw a square analog meter.

This time, in addition to the analog meter, we also placed a text object labeled ‘Potentiometer Value.’

Connecting the Potentiometer

A potentiometer is a variable resistor that allows you to adjust resistance by rotating or sliding, which in turn adjusts the voltage and enables control over signals in an electronic circuit. When connected to an Arduino, it allows easy reading of analog signals, and these values can be used to control other devices or systems.

In this project, we connected the OUTPUT of the potentiometer to Arduino’s A1 pin, and connected VCC and GND accordingly.

Picture by [Fritzing (CC BY-SA)]

Creating the Program to Display on the Touchscreen

This program is designed to reflect the potentiometer’s values directly onto the analog meter displayed on the touchscreen in a simple configuration.

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

 

Interpreting the Program

setMeterRange(0, 240)
This function defines the display range for the analog meter on the GT-SP, set here between 0 and 240, which is the default maximum value. It ensures that the analog meter reflects values within this range based on the potentiometer’s movement.

int meterValue = constrain(map(sensorValue, 0, 1023, 240, 0), 0, 240)

This part of the code uses the map() function to convert the analog value from the potentiometer (ranging from 0 to 1023) to a range of 0 to 240. To ensure that the potentiometer’s rotation intuitively corresponds to the movement of the analog meter’s needle, the mapping direction is reversed. This means turning the potentiometer and the meter needle align properly, avoiding any opposite movement.

The constrain() function ensures that the mapped value is restricted within the 0 to 240 range, ensuring accurate and valid meter readings.

sendMeterValue(meterValue)

This function is crucial as it sends the potentiometer’s value to the analog meter on the GT-SP. It does this by utilizing the gtsp_ObjPrpSet_val() function, which sends the calculated meterValue to the analog meter’s property (Object No. 0, Property No. 0x10). This ensures that the meter on the GT-SP dynamically reflects the potentiometer’s real-time changes.

The maximum value of the analog meter is currently set to 240. To change this, you can modify both the GT-SP and the program accordingly. Alternatively, you can directly change the meter’s maximum value using a command like gtsp_ObjPrpSet_value(0, 0x1F, 240), which targets the analog meter’s max value property.

Execution Results

In this experiment, we used Arduino and a potentiometer to reflect real-time values on the GT-SP analog meter. The meter responded smoothly to the adjustments made via the potentiometer, demonstrating its effectiveness.

Next time, we will explore ways to enhance the design of the analog meter and introduce more refined display techniques.