Circuit Documentation
Summary
This circuit involves an Arduino UNO microcontroller interfacing with an ILI9341 TFT display. The Arduino UNO is used to control the display, sending commands and data to render graphics on the screen. The connections between the Arduino and the display are established through various digital pins, enabling communication via the SPI protocol.
Component List
ILI9341 TFT Display
- Description: A 240x320 pixel TFT LCD display with SPI interface.
- Pins: VCC, GND, CS, RST, D/C, MOSI, SCK, LED, MISO
Arduino UNO
- Description: A microcontroller board based on the ATmega328P.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
Wiring Details
ILI9341 TFT Display
- CS (Chip Select) connected to D4 on Arduino UNO
- D/C (Data/Command) connected to D5 on Arduino UNO
- MOSI (Master Out Slave In) connected to D11 on Arduino UNO
- SCK (Serial Clock) connected to D13 on Arduino UNO
- MISO (Master In Slave Out) connected to D12 on Arduino UNO
Arduino UNO
- D4 connected to CS on ILI9341 TFT Display
- D5 connected to D/C on ILI9341 TFT Display
- D11 connected to MOSI on ILI9341 TFT Display
- D13 connected to SCK on ILI9341 TFT Display
- D12 connected to MISO on ILI9341 TFT Display
Code Documentation
Code Overview
The provided code initializes the ILI9341 display and sets up basic drawing functions. The setup function initializes the display and sets its rotation. It also sets the color and draws a line on the display. The loop function is currently empty but can be used for continuous operations. The sendCommand function is a helper to send commands to the display.
Code Listing
#include "lcdgfx.h"
DisplayILI9341_240x320x16_SPI display(3,{-1, 4, 5, 0,-1,-1});
void setup()
{
display.begin();
display.getInterface().setRotation(0); // Set rotation to 0
// Memory Access Control command to set RGB mode
// sendCommand(0x36, 0x00); // 0x00 sets the display to RGB mode
display.setColor(RGB_COLOR16(255,0,0));
// display.putPixel(0, 0);
display.drawLine(10,30,56,96);
}
void loop()
{
// display.setColor(RGB_COLOR16(255,255,0));
// display.drawLine(10,30,56,96);
}
void sendCommand(uint8_t command, uint8_t data)
{
display.getInterface().startTransaction();
display.getInterface().sendCommand(command);
display.getInterface().sendData(data);
display.getInterface().endTransaction();
}
Code Explanation
- Include Library: The
lcdgfx.hlibrary is included to provide functions for controlling the ILI9341 display. - Display Initialization: The
DisplayILI9341_240x320x16_SPIobject is created with specific pin configurations. - Setup Function:
display.begin()initializes the display.display.getInterface().setRotation(0)sets the display rotation.display.setColor(RGB_COLOR16(255,0,0))sets the drawing color to red.display.drawLine(10,30,56,96)draws a line from coordinates (10,30) to (56,96).
- Loop Function: Currently empty, can be used for continuous operations.
- sendCommand Function: A helper function to send commands and data to the display.
This documentation provides a comprehensive overview of the circuit, including the components used, their connections, and the code to operate the display.
