Example Code for Mango-Pi-SPI TFT LCD

This article offers a comprehensive guide on connecting a TFT LCD screen to a Mango-Pi board, including pin configurations and a Python script example using the ILI9341 library for display control.

Requirements

  • Mango-Pi board with firmware burned ×1
  • TFT LCD Screen ×1

Connect the TFT LCD screen to Mango-Pi

Connect DC, RES, CS, MISO, MOSI, SCLK, GND, VCC to the corresponding positions on the tiny200 board in turn.

Screen Pin Mango-Pi Pin Pinpong Pin
DC PE5 133
RES PE4 132
CS PE7 135
MISO PE10 138
MOSI PE8 136
SCLK PE9 137
GND GND GND
VCC 3V3 3V3

Write the script

import time
from pinpong.board import Board,Pin
from pinpong.libs.dfrobot_ili9341 import ILI9341_SPI #Import ili9341 library

Board("F1C").begin()

dc = Pin(5, Pin.OUT)
res = Pin(4, Pin.OUT)

lcd = ILI9341_SPI(width=240, height=320, bus_num=1,device_num=0, dc=dc, res=res) #Initializes the screen, transmits in the numbers of screen pixels
lcd.begin()

while True:
  lcd.fill(lcd.COLOR_RGB565_BLACK)
  time.sleep(1)
  lcd.fill(lcd.COLOR_RGB565_NAVY)
  time.sleep(1)
  lcd.fill(lcd.COLOR_RGB565_DGREEN)
  time.sleep(1)

Check the result

Use the following command to verify if it succeeded.

python ili.py

70

72

Was this article helpful?

TOP