Arduino 1.77" display: Difference between revisions
From wikiluntti
(→Code 1) |
|||
(5 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
== Connections == | == Connections and Libraries == | ||
{| class="wikitable" | {| class="wikitable" | ||
|+ | |+ | ||
Line 9: | Line 9: | ||
!Name | !Name | ||
!Purpose | !Purpose | ||
! | !No needed? | ||
! | !Constructor 2! | ||
|- | |- | ||
|3.3V | |3.3V | ||
Line 70: | Line 70: | ||
== Theory == | Install and Download library: | ||
* https://adafru.it/dXk | |||
* https://adafru.it/cBB | |||
Sketch -> Include Library -> Add .ZIP Library | |||
== Theory: SPI protocol == | |||
Serial Peripheral Interface | |||
The SPI enabled device typically has the following pins: | |||
* SS: A line indicating slave device selection | |||
* MISO and MOSI (Master In Slave Out): A line for sending serial data to the Master device | |||
* SCK/SCLK (Serial Clock): A clock signal generated by the Master device to synchronize data transmission, so the slave device knows when to read the input. | |||
* RESET: A line for restarting the transmission process. | |||
== Code 1 == | |||
Source code from https://www.arthurwiz.com/software-development/177-inch-tft-lcd-display-with-st7735s-on-arduino-mega-2560 | |||
<syntaxhighlight lang="C"> | |||
#include <Adafruit_GFX.h> | |||
#include <Adafruit_ST7735.h> | |||
#include <SPI.h> | |||
#define TFT_CS 10 | |||
#define TFT_RST 8 | |||
#define TFT_DC 9 | |||
#define TFT_SCLK 13 | |||
#define TFT_MOSI 11 | |||
//Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST); | |||
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST); | |||
void setup(void) { | |||
tft.initR(INITR_BLACKTAB); | |||
tft.fillScreen(ST7735_BLACK); | |||
tft.setTextColor(ST7735_WHITE); | |||
tft.setTextSize(0); | |||
tft.setCursor(30,80); | |||
tft.println("Hello World!"); | |||
delay(1000); | |||
} | |||
void loop() { | |||
tft.fillScreen(ST7735_WHITE); | |||
delay(1000); | |||
tft.setTextColor(ST7735_BLACK); | |||
tft.setTextSize(0); | |||
tft.setCursor(30,80); | |||
tft.println("Toimii!!"); | |||
delay(500); | |||
} | |||
</syntaxhighlight> | |||
== Code 2 == | |||
== Code 3 == | |||
== References == | == References == | ||
https://www.arthurwiz.com/software-development/177-inch-tft-lcd-display-with-st7735s-on-arduino-mega-2560 | https://www.arthurwiz.com/software-development/177-inch-tft-lcd-display-with-st7735s-on-arduino-mega-2560 |
Latest revision as of 17:34, 3 December 2024
Introduction
Connections and Libraries
Arduino | Display | Name | Purpose | No needed? | Constructor 2! |
---|---|---|---|---|---|
3.3V | 8 LEDA | Lite | Backlight control | ||
10 | 7 CS | Chip Select / DC (Data/Command) | SS PIN / SPI data or command selector [SS = Slave Select] | Yes | Yes |
9 | 6 RS | Register Selection | MISO - Sending to Master | Yes | Yes |
8 | 5 RES | Reset / RST | Reset the TFT | Yes | Yes |
11 | 4 SDA | Serial Data | MOSI - Sending to Slave | Yes | |
13 | 3 SCK | SCLK - Clock Line | SPI Clock Input | Yes | |
5V | 2 VCC | Voltage Common Collector | |||
GND | 1 GND | Ground | Ground |
Install and Download library:
Sketch -> Include Library -> Add .ZIP Library
Theory: SPI protocol
Serial Peripheral Interface
The SPI enabled device typically has the following pins:
- SS: A line indicating slave device selection
- MISO and MOSI (Master In Slave Out): A line for sending serial data to the Master device
- SCK/SCLK (Serial Clock): A clock signal generated by the Master device to synchronize data transmission, so the slave device knows when to read the input.
- RESET: A line for restarting the transmission process.
Code 1
Source code from https://www.arthurwiz.com/software-development/177-inch-tft-lcd-display-with-st7735s-on-arduino-mega-2560
#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
#include <SPI.h>
#define TFT_CS 10
#define TFT_RST 8
#define TFT_DC 9
#define TFT_SCLK 13
#define TFT_MOSI 11
//Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);
void setup(void) {
tft.initR(INITR_BLACKTAB);
tft.fillScreen(ST7735_BLACK);
tft.setTextColor(ST7735_WHITE);
tft.setTextSize(0);
tft.setCursor(30,80);
tft.println("Hello World!");
delay(1000);
}
void loop() {
tft.fillScreen(ST7735_WHITE);
delay(1000);
tft.setTextColor(ST7735_BLACK);
tft.setTextSize(0);
tft.setCursor(30,80);
tft.println("Toimii!!");
delay(500);
}