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

Controlling an LED Connected to Arduino Using Form Controls

Controlling an LED Connected to Arduino Using Form Controls

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.

Last time, we built a system to control the range of motion of a slider equipped on the GT-SP. This time, we will use form controls such as radio buttons and checkboxes that can be mounted on the GT-SP to control an LED.

To read this article, you should first review the previous contents (“Controlling a Servo Motor Connected to Arduino from a Touch Screen“, “Display values obtained from Arduino in a highly visible design“). We will be applying object decoration techniques introduced there, so please check the previous articles if you haven’t yet.

Connecting LEDs

For this project, we will use three LEDs of different colors, each with a resistor ranging from 300Ω to 1kΩ. Follow these pin connections:

  • Connect the red LED to pin 9
  • Connect the green LED to pin 10
  • Connect the blue LED to pin 11

Additionally, connect each LED to GND. When connecting the LEDs, make sure to pay attention to their polarity. Connect the longer pin to the designated Arduino pins (9, 10, 11) and the shorter pin to GND.

Picture by [Fritzing (CC BY-SA)]

Creating Screens in GT Design Studio

This time, we will use checkboxes, radio buttons, and dropdowns on one page. By sending the state of these controls to Arduino via the provided SET buttons, it is possible to control LEDs.

  • First SET Button (the left button): Sends the state (ON/OFF) of the checkboxes selecting the prepared colors to Arduino (CHK is sent).
  • Second SET Button (the middle button): Sends the state of the radio buttons, which select the LED state (solid, blinking), to Arduino (RAD is sent).
  • Third SET Button (the right button): Sends a preset LED behavior selected from the dropdown menu to Arduino and executes it (DROP is sent).

Refer to the previous article for design details around titles and buttons.


Each checkbox needs to be placed individually. This time, three checkboxes are prepared.

The settings for the design of checkboxes are as follows:

  • Check Size: Set to 32 (default size is 20).


Radio Buttons

Radio buttons increase in items according to the “row” placed in “Text0”.

This time, two items, “Solid on” and “Blinking”, are required. Each checked item is assigned a “VAL”. In this example, “Solid on” is assigned a VAL of “0”, and “Blinking” is assigned a VAL of “1”.


This time, “DEMO 1” and “DEMO 2” are added to the dropdown. Each is assigned a VAL of “0” and “1”, respectively.

Similar to radio buttons, dropdown items increase according to the rows placed in “Text 0”.

 If the rows increase, the items are hidden, and a scrollbar appears. You can change the display area by modifying the Style > Dropdown Size property of the dropdown. If you plan to increase the rows and do not need a scrollbar, you should change the size (default value is 100).

First SET Button Event Setting

The first SET button (the left button) includes the following Event.

Second SET Button Event Setting

The second SET button (the middle button) includes the following Event.


Third SET Button Event Setting

The third SET button (the right button) includes the following Event.

Project Creation to Write on the Touch Screen

This program receives commands from an external device via serial communication and controls the LED lighting state and demo mode.

Specifically, it controls the turning on and off of LEDs according to the received commands. The “CHK” command updates the check state of the specified LEDs, the “RAD” command sets the LED blinking mode, and the “DROP” command switches the demo mode. In demo mode, LEDs light up in sequence according to the settings, providing visual feedback to the user.

Through data transmission and reception via serial communication, this project achieves flexible and efficient LED control.

Program Analysis

This program manages the LED lighting state and demo mode based on commands sent from an external device via serial communication. When data is received within the loop function, different processes are executed according to the content of the data.

Pre-Knowledge: Explanation of the gtsp_ObjPrpRead_val Function

The newly added gtsp_ObjPrpRead_val function sends the specified object number, property number, and data length, and receives the property data. For example, the code LED1Check = gtsp_ObjPrpRead_val(3, 0x10, 4); reads the value of property number 0x10 of object number 3 and stores the value in the LED1Check variable. This determines whether LED1 is on or off.

Controlling LED States

When the “CHK” command is received, the check state of a specific LED is updated. The check state of each LED is obtained using the gtsp_ObjPrpRead_val function, and based on the result, the LED is turned on or off.

Global Blinking Control

When the “RAD” command is received, the blinking state of all LEDs is set. By updating the BlinkingMode< variable, the LED blinking mode is switched on or off. This determines whether all LEDs blink simultaneously.

Managing Demo Mode

When the “DROP” command is received, the demo mode is switched. In this mode, LEDs light up in a specific pattern, providing a visual effect. When another command is received, the demo mode is automatically deactivated.

This program has the flexibility to appropriately control various functions based on the received commands. Each function is independent and designed to respond quickly and accurately.

Execution Result

This project involved controlling LEDs by integrating form controls and Arduino. Using such a system, it can be useful for remotely controlling home electrical switches or for smart home automation.

Next time, we will take on a project using outline fonts and the Draw Shape tool to decorate the screen.