Connecting touchscreen to arduino uno. Connecting TFT display with ILI9341 driver to Arduino

This article describes how to connect TE-ULCD to Arduino and how to use it with Ethernet Shield v2. In the process of studying the module, we got a library and a small sketch that receives from the Internet and displays the time in UTC format, the state of road traffic in Moscow using the Yandex.traffic service, and the weather using the GisMeteo informer service.

This module was chosen by me as one of the few ready-made solutions based on the SPI interface available in the Russian Federation, that is, it does not require many (16-32) pins for control.

TE-ULCD is produced by Terraelectronics LLC. The module is based on a 3.5” (or 5.6”) color graphic touch screen display and a 32-bit ARM-7 microcontroller. Maintenance of a color graphic display using a specialized microcontroller makes it possible to separate the functions of displaying information and control and makes it possible to provide a human-machine interface in various information and control systems. At the manufacturing stage, a library of graphic functions is loaded into the microcontroller program memory. Functions can be called from an application program using SPI commands. This greatly simplifies the formation of the image on the TFT display, as well as maintenance of the touch screen. It is possible to update the loaded library. To store images in BMP format, use a microSD memory card.

Required Components

Connection

The display module is powered by 5 volts direct current, in the user manual, the manufacturer indicates a nominal current of 0.2 A. I measured the current consumption using a digital power supply, it turned out to be stable 0.299 A, so you should focus on 0.3 A. When powered by TE-ULCD from arduino, the voltage converter installed on the board heated up quite strongly, so just in case, I powered the display module from the USB of a personal computer, taking a cord from an old mouse. The X8 TE-ULCD connector is designed for power supply and has the following pinout: PIN 1, 3, 7 and 9 - 5 V input, PIN 2, 4, 6, 8, 10 - GND, PIN5 is used as a key to control the correct connection. You can supply power to any one pin +5 V and GND.
The Arduino is connected to the X6 connector of the display module, according to the diagram shown in the figure. SPI TE-ULCD operates at a level of 3.3 V, so you should match the levels of the display module and arduino using a simple resistor divider.
Since it is planned to use the TE-ULCD and the Ethernet Shield together, PIN9 and PIN10 will be used to select the controlled (slave) devices, respectively. PIN9 was chosen based on the convenience of connection and you can use any other free one by changing the value of slaveSelectPin in the sketch.

The TE-ULCD write and read commands correspond to the SPI settings CPOL=1 and CPHA=1, which corresponds to SPI_MODE3 for arduino. For Ethernet Shield v2, the SPI settings are SPI_MODE0. These settings will be needed to access the corresponding module.

Program description

The program described in the article uses the ULCD library specially prepared for arduino. Pictures for TE-ULCD should be written to microSD.

The description of commands, registers and messages of the TE-ULCD graphic module used in the ULCD library was taken from the operator's manual for the TE-ULCD35/56 modules. The TE-ULCD module supports two modes of operation: terminal and mode of operation using the library of graphic functions (shown in this example).

Currently, the set of built-in widgets (graphical user interface primitives) of TE-ULCD includes:

    Frame (0x01). Required, used to place widgets.

    Window (0x00). Designed for placing widgets, has a specified set of properties.

    Panel (0x06). Designed for placing widgets, has a specified set of properties.

    StaticLine (0x12). Represents a line with a shadow, can be used to separate some components from others.

    Button (0x0A). Allows you to place a button and perform some action when you click on it.

    Text (0x07). Used to display text on the screen.

    Bitmap (0x05). Designed to display images in bmp format.

    RotateControl (0x0B). Designed to display the image of the regulator in the form of a rotating "wheel".

    Slider (0x0C). Designed to display the image of the regulator in the form of a "slider".

Using the ULCD Library

The following procedures are implemented in the ULCD library for arduino for working with the TE-ULCD universal display module:

    ULCD() - constructor;

    void RESET() - program reset of the module;

    void digitalPortWrite(byte value) - send one byte from arduino to TE-ULCD;

    void LOAD_FONT(byte R, String FileName) - load font from TE-ULCD flash memory into TE-ULCD register;

    void LOAD_PICTURE(byte R, String FileName) - loading a picture in BMP format from a microSD card into the TE-ULCD register;

    void LOAD_TEXT(byte R, String Text) - loading a text string from arduino into the TE-ULCD register;

    void LOAD_SCRIPT(byte R, byte Number) - load script from arduino to TE-ULCD register;

    void SET_SIZE(int X, byte Y) - setting the widget size;

    void SET_POS(int X, byte Y) - setting the position (lower left corner) of the widget;

    void SET_BACK_COLOR(byte R, byte G, byte B) - setting the background color of the widget;

    void SET_FONT_COLOR(byte R, byte G, byte B) - setting the widget's font color;

    void SET_FONT(byte R) - set widget font from TE-ULCD register;

    void SET_MAIN(byte R) - setting the widget as the main one (applies only to the frame);

    void SET_SCALE(byte min, byte max, byte pos) - setting the minimum, maximum and default values ​​of the widget (for slider and "wheel");

    void SET_SCRIPT(byte R) - setting the script for the widget (the action that will be performed by TE-ULCD on a given event) from the TE-ULCD register;

    void SET_TEXT(byte R) - setting a string for the widget from the TE-ULCD register;

    void SET_PICTURE(byte R) - setting a picture in BMP format for a widget from the TE-ULCD register;

    void SEND_REG(byte R1, byte R2) - send the contents of register R2 to R1;

    void WRITE_REG(byte R, byte value) - write value to specified TE-ULCD register;

    void CR_WID(byte WidType) - creating a widget of the specified type (from the list of built-in TE-ULCD widgets);

    byte READ(byte R) - reading the contents of the TE-ULCD register;

    void REPAINT_TEXT(byte R1, byte R2, String Text) - replace (redraw) the widget's text stored in the R1 register with the text passed in the Text variable, save the text in the R2 register;

    void REPAINT_BMP(byte R1, byte R2) - redraw the widget's image stored in register R1 onto the image stored in register R2;

For example, the background image in the program is set as follows:

#include ULCD LCD; // ... lcd.LOAD_PICTURE(1 , "back.bmp" ) ; //Load the image from microSD into register R1 lcd.CR_WID(5) ; //Create a BitMap widget (for background) lcd.SET_SIZE (320 , 240 ) ; //Set BitMap size to TE-ULCD35 screen size lcd.SET_POS (0 , 0 ) ; //Set the position of the BitMap lcd.SET_PICTURE(1) ; //set the image for the widget from register R1

For user convenience, TE-ULCD has 32 general-purpose registers (R0-R31) for storing pointers to widgets (images, text, scripts). If desired, pointers can be stored in arduino.

Get traffic status

I wanted to make my own traffic light right after I saw a similar one in Yandex, only there it was controlled from a PC, but I still want an autonomous one - only arduino and Ethernet Shield. It is impossible to receive a direct request about the traffic status from the Yandex.Traffic server. A letter to the technical support team of Ya.probka also did not help: “Thank you for your attention to our service. We do not supply such information. Try it, connect the traffic jams module and use the "Jams" control.”

To get the status of road traffic, I used the informer, or rather the picture that is transmitted in it. The algorithm of actions is as follows:

    We connect to the server (info.maps.yandex.net);

    We analyze the received image, it is transmitted in the PNG standard (0xFF 0xA4 0x00 yellow, 0x3F 0xBB 0x00 green, 0xFF 0x2A 0x00 red), the presence of colors is unique for each green-yellow-red state (even more, by counting the number of pixels of each color, you can determine the score traffic jams, not just color);

    We display the picture on the TE-ULCD screen.

The informer image request looks like this:

GET http://info.maps.yandex.net/traffic/moscow/current_traffic_88.gif HTTP/1.1 Accept: image/gif Accept-Language: en-US; Cache-Control: max-age=0 Host: info.maps.yandex.net User-Agent: Chrome

This request is suitable for Moscow, but you can request the status of traffic in any city for which the Ya.probki informer service works. This block, with a little refinement, can be used to control your own traffic light using an arduino and a relay, it will be like in Yandex :).

getting time

The simplest and easy way to get the time in UTC format - send a request to some server (at first I used Google, but then to save memory I switched to the Yandex.tube server) and parse the answer, the line thus obtained looks like:

At the moment, the request to get the time looks like this:

GET http://info.maps.yandex.net/traffic/moscow HTTP/1.1

The accuracy of such time is not high - up to minutes, but it is suitable for simple watches.

Getting a weather forecast

To get the weather forecast for the next day, I used the GisMeteo informer service in XML format. Weather data is a detailed summary of all meteorological parameters, with a step of 6 hours and a lead time of one day. Everything is simple here, we indicate the city in the request and receive a weather forecast for it in response, parse it and display the forecast for the next 6 hours on the screen.

int freeRam () ( extern int __heap_start, * __brkval; int v; return (int ) & v - (__brkval == 0 ? (int ) & __heap_start : (int ) __brkval) ; )

If someone tells me how to improve the program, I will be grateful :), there are discussions

In this article we will talk about touch buttons in arduino. With this simple and inexpensive component, you can create simple and very effective projects. Most often, such buttons are used to create all sorts of convenient touch interfaces, for example, in smart home systems. Let's find out how you can connect touch buttons to arduino, write a simple sketch and be sure to consider how they work.

It's no secret that progress does not stand still. New technologies are constantly emerging, old ones are being improved. Touch screens have appeared quite recently (by the standards of mankind), but have already firmly entered our daily lives. Phones, TVs, terminals and others mostly use “buttonless” technologies. This word is in quotation marks for the reason that they still use buttons, only touch ones. In this article, we will just talk about them, or rather, about the Touch module for Arduino.

The principle of operation of the touch buttons

Modules with touch buttons mostly use projected capacitive touch screens (https://ru.wikipedia.org/wiki/Touch_screen). If you do not go into spatial explanations of their work, to register the pressure, the calculation of the change in the capacitance of a capacitor (electric circuit) is used, while an important feature is the ability to set a different initial capacitance, as we will see later.

Human body has some electrical capacitance, and therefore, low reactance for alternating electric current. If you touch your finger or any electrically conductive object, then a small leakage current from the device will flow through them. A special chip detects this leak and sends a signal to press the button. The advantages of this technology are: relative durability, low impact of pollution and resistance to water ingress.

Touch or mechanical buttons

The touch button "feels" pressing even through a small layer of non-metallic material, which provides variety in use her in various projects.

This one also follows from the previous paragraph - the ability to use the touch button inside the case increases attractiveness project, which does not affect the functionality, but is quite important in Everyday life to ignore it.

+stable operation, which is expressed by the absence of moving parts and frequent calibration (which will be discussed below). You don't have to worry about the button rattle that occurs when using a mechanical counterpart, which will make life much easier for a beginner arduino. Therefore, another plus, albeit not for everyone - ease of operation.

Of the minuses, the following can be noted:

  • Touch buttons do not work well at sub-zero temperatures, therefore they are unsuitable for outdoor use.
  • high electricity consumption, caused by the need to constantly maintain the same capacity.
  • The touch button does not work when pressed with a gloved hand or a poorly conductive object

Overview of touch buttons

Before talking directly about working with the module, you need to decide which model to buy for use. Consider several options for different companies:

1. Troyka touch sensor

Response time: 80ms (in power mode) and 10ms (in high speed mode)

4 mm

The size: 25X25 mm

Supply voltage: 3-5 V

Response time: 220ms and 80ms

Maximum dielectric thickness for normal operation: 2 mm

The size: 20x20 mm

Supply voltage: 2-5V

Timeresponse: 220ms and 60ms

The size: 24X24 mm

Supply voltage: 2-5V

The size: 30x20 mm

Supply voltage: 3.3–5 V

Connecting a touch button to Arduino

To use the touch button, as well as all other modules and sensors, it must be connected to any arduino board. In most cases, standard modules with three pins are used: power, signal and ground. Their locations vary from model to model, they are shown on the diagram according to the recent listing (the touch button is replaced by a switch due to its absence in Tincercad):

An important point to remember is that the touch button needs an average of half a second calibration during each launch, so you don't have to worry about extra noise that would undoubtedly arise due to different button positions in projects. Therefore, you should not press the button immediately after starting, because. after that, the device is most likely to malfunction.

The touch module is essentially similar to a digital button. While the button is pressed, the sensor gives a logical one, and if not, then a logical zero.

Touch Button Projects

Let's start with a simple one: when you press the button, the built-in LED lights up.

Const int buttonPin = 7; // Set the values ​​of the port connected to the signal port of the button void setup() ( pinMode(LED_BUILTIN, OUTPUT); // Command for adequate response of the LED pinMode(buttonPin, INPUT); // Open the port for reading ) void loop() ( buttonState = digitalRead(buttonPin); // Read the button status (pressed / not pressed) if (digitalRead(buttonPin)) ( // If the button is pressed... digitalWrite(LED_BUILTIN, HIGH); // Apply voltage to LED_BUILTIN - value for built-in LED ) else ( // Else... digitalWrite(LED_BUILTIN, LOW); // Do not apply voltage ) )

Now let's complicate the task: Pressing the button changes the mode of the LED.

Const int buttonPin = 7; // Set the values ​​of the port connected to the signal port of the button int count = 0; // Variable for selecting the operating mode void setup() ( pinMode(LED_BUILTIN, OUTPUT); // Command for adequate response of the LED pinMode(buttonPin, INPUT); // Open the port for reading ) void loop() ( if(digitalRead (buttonPin))( // When the button is pressed... count = count + 1; // Change the button mode if(count > 2)( //If the count value is exceeded, start counting from the beginning count = 0; ) while(digitalRead( buttonPin))( // An empty loop to wait for the user to release the button ) ) if(count == 0) ( // 3 modes for toggling the button: digitalWrite(LED_BUILTIN, LOW); // 1: LED off ) else if( count == 1) ( digitalWrite(LED_BUILTIN, HIGH); // 2: On ) else ( digitalWrite(LED_BUILTIN, HIGH); // 3: Flashing delay(100); digitalWrite(LED_BUILTIN, LOW); delay(100); ) )

Conclusion

In this article, we have examined the principle of operation and the connection diagram of the touch button to the Arduino boards. From the point of view of the software model, there are no special differences when working with this type of buttons. You simply analyze the level of the incoming signal and decide on your action. Considering that the touch button modules themselves are quite cheap and available in a large number of online stores, it will not be difficult to add such an interesting and modern interface to your Arduino project.

Display 2.4 TFT 240x320 touch + MicroSD

The module is a 2.4-inch color QVGA color LCD monitor with a touch screen. It is designed to work in conjunction with various types of microcontrollers and processor systems. While it is possible to display full color photographs, the main application is the display of simple graphics and character data using 16 colors. You can display animation on the screen:

The graphic capabilities of the monitor are enough to create an image of a keyboard that works thanks to touch surfaces. Simultaneously with the processing of pressings, the display 2.4 TFT 240x320 touch + MicroSD displays the results of the execution of the operator's commands and indicates the values ​​of the monitored parameters. The application greatly simplifies the input-output devices of the device. The LCD indicator has a permanently on backlight. There is one button. There is a container for an SD card on the board.

Characteristics 2.4TFT240x320

Food
Voltage 5 V
Current 300 mA
Input signal voltage 5 or 3.3 V
Diagonal 2.4 inches
Resolution 320 X 240 dots with individual control
Maximum amount shades 262144
Backlight white
Interface 8080
Maximum microSD card capacity 32 GB
Dimensions 71 x 52 x 7 mm

Contacts

The LCD indicator uses 8 module contacts for data transmission and 4 contacts for control signals. The touch part of the display shares 4 pins with the LCD. Working with Micro SD card requires 4 pins.

Contact
3.3V Power
5V power supply
GND Power
J4-1 Button

LCD indicator and touch surface

LCD_RD LCD control, reading
LCD_WR TOUCH_YP LCD control, write or touch surface data
LCD_RS TOUCH_XM LCD control, command/data or touch surface data
LCD_CS LCD control, device selection
LCD_RST reset
LCD_D2 LCD data
LCD_D3 LCD data
LCD_D4 LCD data
LCD_D5 LCD data
LCD_D6 / TOUCH XP LCD data / touch surface data
LCD_D7 / TOUCH YM LCD data / touch surface data
LCD_D0 LCD data
LCD_D1 LCD data

SD_CS selection
SD_DI SD data input
SD_DO data output
SD_SCK data clock

Display 2.4 TFT 240x320 touch + MicroSD can be installed in Arduino connectors.

Connection to Arduino UNO:

Module contacts Arduino
LCD_CS A3
LCD_RS A2
LCD_WR A1
LCD_RD A0
LCD_RST A4, you can connect LCD_RESET to the Arduino UNO RESET line as described below.
LCD_D0 DIO 8
LCD_D1 DIO 9
LCD_D2 DIO2
LCD_D3 DIO 3
LCD_D4 DIO4
LCD_D5 DIO 5
LCD_D6 DIO 6
LCD_D7 DIO7
SD SS DIO 10
SD DI DIO 11
SD DO DIO 12
SD SCK DIO 13
3.3V 3.3V
5V 5V
GND GND


When installing in the Arduino UNO pins, before turning it on, you should check that the USB connector is not touched by the pins of the board and, if necessary, glue an insulator on the board.

Scheme

Display 2.4 TFT 240x320 touch + MicroSD.

5 volt power is supplied to the circuit circuits and the U1 microcircuit, a voltage regulator of 3.3 volts. Information signals pass through 74xx541 microcircuits - data bus buffers. IC1 chip ADS7843 - touch screen controller. This is a 12-bit ADC with a sample-and-hold device, a synchronous serial interface, and low-resistance touch contact switches.
The main component of the module is a TFT1 LCD screen combined with a specialized controller. Links to the description of the LCD and various types of controllers at the end of the page.

Button

There is a button on the edge of the module board. In addition to the touch keyboard, the display 2.4 TFT 240x320 touch + MicroSD has a mechanical button. Its contacts are connected to a common wire, pin 1 of connector J4. This is an unsigned contact located on the edge of connector J4 near pin 3V3. The button can be used for the needs of the device being assembled. When used with an Arduino, pin 1 of J4 is connected to the reset line. Pressing the button resets the Arduino.

Beginning of work

Most of the module's operation belongs to the microcontroller program. To do this, it is convenient to use existing software solutions published on the Internet. They take programs written for Arduino as a basis and modify them to fit the hardware of the device being developed.
When we try to rein in the 2.4 TFT 240x320 touchscreen + microSD display, we get unexpected results: a white screen, the whole screen is noisy, touch functions do not work or the Y position is inverted, colors are inverted. The fact is that various manufacturers install different types of the main LCD controller in the display: ST7781, Spfd5408, IL9341, Sitronix ST7783262K, S6D0154 and others. Their descriptions are at the bottom of the page. First of all, you need to determine what type of display controller is used in your module. Chip and LCD screen are one device. The type can only be set programmatically. To do this, use the Arduino UNO microcontroller module and the LCD_ID_Reader Version 1.2 program, which reads the chip ID. LCD_ID_Reader does not require any additional libraries to be installed. There is also a program for determining the type of controller in the samurai library, which will be discussed later.

Arduino software

Different libraries have been developed for different LCD controllers.

JoaoLopesF. In fact, this is a library from Adafruit modified for SPFD5408. It has the ability to calibrate the touch screen.

For controllers
S6D0154 2.8" diagonal
ILI9488 3.95" diagonal 320 x 480 dots
ILI9327 diagonal 3.6 inches
ILI9341
NT35702, compatible with ILI9327
Samurai Library
By default, this library is designed for screens with a diagonal of 2.8 inches. On smaller ones, part of the image disappears. For a diagonal of 2.4 inches in the TFTLCD-Library/Adafruit_TFTLCD.cpp file, you need to neutralize the lines:

//#define TFTWIDTH 320
//#define TFTHEIGHT 480

And remove the comment characters in the lines:

#define TFTWIDTH 240
#define TFTHEIGHT 320

The program for determining the type of LCD controller is graphicstest. The serial port monitor will display the LCD controller type.
For touch screen operation, change #define YP A1 #define XM A2 #define YM 7 #define XP 6

For controllers
ILI9325
ILI9328
And for the controller with identification code 0xC505
adafruit/TFTLCD-Library

For ST7781 controller set:
Smoke-And-Wires/TFT-Shield-Example-Code
adafruit/adafruit-GFX-Library
adafruit/Touch-Screen-Library

Library installation, testing, library description, fonts, aboutdetection of pressure coordinates, work with microSD card, conversion from 24-bit to 16-bit format

Touch surface

Display 2.4 TFT 240x320 touch + MicroSD transmits three values ​​to the program: pressing coordinates (X and Y) and pressure Z. Resistive touch screen technology is used.

The surface consists of two polymer layers coated with a resistive material acting as electrodes. The layers stick together at the edges. Under the control of the program, the data comes from the IC1 chip to detect pressing. The instrument's microcontroller receives a 10-bit number (0..1023) for each axis. Programmatically, this value is scaled according to the screen size.

Five wires of the touch surface (four signal and one common) are connected via a thin cable to the LCD controller.

The SPFD5408 controller uses the 4-wire resistive touchscreens library. Copy the unzipped and renamed folders:

The ST7781 LCD controller uses the pressure control library. Also install . Download and unzip the demo code. Copy the SWIFT-Shield folder from the extracted archive to the Arduino libraries folder.

Graphics Test

For module with IL9341 controller.

Connect the display 2.4 TFT 240x320 touch + MicroSD to Arduino UNO. Download the adafruit/TFTLCD-Library and Adafruit-GFX-Library libraries.

Try the graphictest example in the adafruit/TFTLCD library. The screen should display an image as shown above. If the display 2.4 TFT 240x320 touch + MicroSD does not display anything or only shows a static picture, then you can try to change the graphictest program. The modification of the program consists in hard setting the display controller type. Line 60 replace with:

Uint16_t identifier = 0x9341; //Need hardcode here (IC)

For LCD controller SPFD5408.

Create two graphic files in BMP format with the following parameters: 320 pixels image width, 24-bit color and no more than 250 KB. The file name must consist of eight Latin letters. Copy the file to the root directory of the microSD card. If the experiment is successful, then many pictures can be recorded on the card. The test will display them one by one.

Download the following libraries:
TFT-Shield-Example-Code
Unzip and copy to the SWTFT-Shield folder in the Arduino libraries.

Connect USB cable to PC and open Arduino IDE. Next open Under File->Examples –> SWTFT-Shield.

Results of program examples.

graphics test

rotationtest.
Open the Arduino IDE Serial Monitor and select baud rate 9600 and New Line at the bottom of the window. When you click on the Send button, various images will appear.

Ttfbmp.
BMP files recorded on the micro SD card will be displayed on the screen.

ttfpaint.
You can choose any color to draw or write on the touch screen.

There are a lot of modules and sensors for Arduino. But all this is boring without a display)) In this article, we will connect a TFT display with the ILI9341 driver to the controller.

A Chinese brother with the KMRTM24024-SPI marking fell into my hands. This is a 2.4″ TFT display with SPI interface.

Characteristics:

  • Diagonal: 2.4 .
  • Colour: 18-bit, 262,000 shades.
  • Resolution: 320 x 240.
  • Screen aspect ratio: 4:3.
  • Power supply: 3.3V/5V.
  • Interface: SPI

The most interesting thing is that 3.3 V driver logic . Therefore, we will need to match our Arduino with 5V logic and a display.

Conclusions:

  • VCC = +5v (+5 volts).
  • GND = GND (ground).
  • LED = +3.3v (display backlight).
  • SCK = SPI.
  • SDI/SD (MOSI) = SPI.
  • SDO(MISO) = SPI.
  • CS = device selection.
  • D/C = Command/Data.

Wiring diagram:

Since the logic of the display and the controller is different, we need to coordinate them. There are two options here:

When to enter A+5 volts is applied, at the output G will be +3.3 V. I think the principle of operation is clear.

Display connection with Arduino Nano:

SCK -- pin D8 (through divider).
SDI (MOSI) -- pin D9 (through a divider).
D / C - pin D10 (through a divider).
RESET -- pinD 11 (via divider).
CS -- pin D12 (through divider).
VCC -- +5v (+5 volts, ATTENTION your display can be powered by 3.3V)
GND -- GND (ground).
LED -- +3.3v (display backlight).

Coding:

There are many different libraries for working with the display. I am using the library UTFT which we download from GitHab or from our site. Let's upload the finished sketch from the examples with our permission:

// library for working with the display #include // create an object of the UTFT class // and pass the display model ID and pin numbers // to which the SCK, SDI (MOSI), D/C, RESET, CS lines are connected // UTFT myGLCD(TFT01_22SP, SDI (MOSI),SCK , CS ,RESET , D/C); UTFT myGLCD(TFT01_22SP, 9, 8, 12, 11, 10); // declarations of built-in fonts extern uint8_t SmallFont; extern uint8_t BigFont; extern uint8_t SevenSegNumFont; void setup() ( ) void loop() ( // initialize display with vertical orientation myGLCD.InitLCD(0); // clear screen myGLCD.clrScr(); // select big font myGLCD.setFont(BigFont); // print line in the center of the top line of the display myGLCD.print("TFT01_22SP", CENTER, 0); // select a large font myGLCD.setFont(SmallFont); // print the line at the specified position line myGLCD.print("Hello from Amperka!", CENTER, 50); // select a sesisegment font myGLCD.setFont(SevenSegNumFont); // print a string at the specified position string myGLCD.print("12345", CENTER, 100); // wait 1 second delay(10000); // initialize the display with landscape orientation myGLCD.InitLCD(1); // clear the screen myGLCD.clrScr(); // select a large font myGLCD.setFont(BigFont); // print a line in the center of the top line of the display myGLCD.print("Hello, user!", CENTER, 0); // select a large font myGLCD.setFont(SmallFont); // print a string at the specified position string myGLCD.print("T he screen is 2.2 diagonal", CENTER, 50); // select session font myGLCD.setFont(SevenSegNumFont); // print the string at the specified position string myGLCD.print("67890", CENTER, 100); // wait 1 second delay(10000); )

This example will help you convert float to string:

Arduino-FloatToString #include // included for floatToString function String floatToString(float x, byte precision = 2) ( char tmp; dtostrf(x, 0, precision, tmp); return String(tmp); ) void setup() ( float f = -17.06f ; // some float number String str = floatToString(f); // conversion call // print over serial Serial.begin(9600); Serial.println(str); ) void loop() ( )