Example Code for Arduino-Display Basic Graphics

This guide offers step-by-step instructions to create basic graphics using an Arduino-compatible board and a 3.5 TFT Resistive Touch Shield, covering hardware and software setup, wiring, and sample code for visual displays.

Hardware Preparation

Software Preparation

Wiring Diagram

The 3.5 TFT Resistive Touch Shield connects directly on top of an Arduino pin compatible device (no additional wiring required).

Sample Code

Basic function could be found from the library file <libraries\DmTftLibrary\DmTftBase.h>

 #include <SPI.h>
 #include <DmTftSsd2119.h>
 DmTftSsd2119 tft = DmTftSsd2119(10, 9);// Define the function body

 void setup ()
 {
   tft.init();//Initialization screen
 }
 void loop()
 {
  tft.drawString(5, 10,"  Romantic cabin");//Displays a string
  int x=160,y=50;
  tft.drawLine (x, y, x-80, y+30, YELLOW );//Draw line
  delay(1000);
  tft.drawLine (x, y, x+80, y+30, YELLOW );
  delay(1000);
  tft.drawLine (x-60, y+25, x-60, y+160, BLUE  );
  delay(1000);
  tft.drawLine (x+60, y+25, x+60, y+160, BLUE  );
  delay(1000);
  tft.drawLine (x-60, y+160, x+60, y+160,0x07e0  );
  delay(1000);

  tft.drawRectangle(x-40, y+50,x-20, y+70, 0x8418); //Draw rectangle
  delay(1000);
  tft.drawRectangle(x+40, y+50,x+20, y+70, 0x07ff);
  delay(1000);
  tft.fillRectangle(x-20, y+100, x+20, y+160, BRIGHT_RED);//Draw fill rectangle
  delay(1000);
  tft.drawLine (x, y+100, x, y+160, WHITE  );
  delay(1000);

   tft.fillCircle(x+120, y-20, 20, RED );//Draw fill Circle
   delay(1000);

 }

Result

The house design pattern will be displayed on the screen, as shown in the image below.

DFR0348 3.5 TFT Resistive Touch Shield Result

Was this article helpful?

TOP