步骤1:引脚布局

此处的第一张照片显示了显示板的背面。引脚有两个侧面-红色圆圈表示我们将要使用的侧面。它有8个引脚,您可以在第二张照片中看到每个引脚对应的含义。带有16针的另一侧用于SD卡,将在以后的Instructable中进行介绍。

引脚的简要概述(改编自Adafruits的详尽摘要):

RST -这是TFT复位引脚。接地以复位TFT!最好由库控制此引脚,以便清晰地重置显示器,但您也可以将其连接到Arduino Reset引脚,该引脚在大多数情况下都可以使用。

CS -这是TFT SPI芯片选择引脚

D/C -这是TFT SPI数据或命令选择器引脚

DIN -这是SPI主输出从输入引脚(MOSI),用于将数据从微控制器发送到SD卡和/或TFT

SCLK -此是SPI时钟输入引脚

Vcc -这是电源引脚,连接到5VDC-具有反极性保护,但请尝试正确连接!

BL -这是背光控制的输入。连接到5VDC以打开背光。

GND -这是电源和信号接地引脚

现在我们知道我们要处理的是什么是时候开始布线了!

步骤2:建立连接

这是我要做的步骤希望当我开始使用此板时能够更容易找到。收到屏幕并意识到我不知道如何将其连接起来后,我转向他们的产品的Adafruit指南。

起初,看似引脚的布局不同,但否则两个显示器可以互换,并且能够运行Adafruit Graphics库(有关下一步代码的更多信息)。但是,当我按照Adafruit指南连接董事会时,我的显示 种 起作用了。它确实显示了文本和绘图,但是图像中有很多噪点,并且图像在屏幕上呈条纹状。屏幕顶部还发出明亮的光,中断了图像质量。我以为是因为我在5V电压下运行屏幕,因此需要较低的功率。我尝试了3.3V,但显示效果却变差了。经过约10分钟的遗憾后,我决定购买edaBay,并希望自己能与Adafruit主板一起使用,我决定在Google上搜索我的问题,并发现了这篇有关类似问题的有用文章:(1.8in SPI 128x160 TFT Module Arduino)

简而言之,在5个连接之间需要1k欧姆电阻。您可以在Fritzing图中看到电阻器的位置。第二张图片是显示器和Arduino引脚之间的连接表。我在下面列出了它们,并指出了连接是否需要电阻。

RST -Arduino Pin 7-1k电阻

CS -Arduino Pin 9-1k电阻器

DC -Arduino Pin 8-1k电阻器

DIN -Arduino Pin 11 -1k电阻

CLK -Arduino引脚13-1k电阻

Vcc -5V

BL -5V

GND -GND

步骤3:上传代码并运行

您将需要安装两个库才能操作显示器:

ST7735库

Adafruit GFX库

下载每个库并解压缩文件夹。将它们重命名为“ Adafruit_ST7735”和“ Adafruit_GFX”,并将每个文件夹放置在Arduino Libraries文件夹内。我已将库的屏幕快照附加在正确的文件夹中。安装完成后,就可以操作屏幕了! Adafruit ST7735库内部有一个名为graphicstest.ino的文件,您可以将其上传到Arduino,它将通过许多将对象绘制到屏幕上的函数来运行。但是,此文件将需要进行一些更改以使引脚适应您的布局。

或者,您可以将下面的代码复制/粘贴到Arduino IDE中并上传。这是Adafruit的graphictest.ino的修改版本,主要区别在于引脚的分配。我还玩了一下代码,看看有什么功能。如果您遇到任何代码问题,请告诉我。

/***************************************************

This is a library for the Adafruit 1.8“ SPI display. This library has

been modified from the original version to work with a non-Adafruit

1.8in display.

This library works with the Adafruit 1.8” TFT Breakout w/SD card

----》 http://www.adafruit.com/products/358

The 1.8“ TFT shield

----》 http://www.adafruit.com/products/358

The 1.44” TFT breakout

----》 http://www.adafruit.com/products/358

as well as Adafruit raw 1.8“ TFT display

----》 http://www.adafruit.com/products/358

Check out the links above for our tutorials and wiring diagrams

These displays use SPI to communicate, 4 or 5 pins are required to

interface (RST is optional)

Adafruit invests time and resources providing this open source code,

please support Adafruit and open-source hardware by purchasing

products from Adafruit!

Written by Limor Fried/Ladyada for Adafruit Industries.

MIT license, all text above must be included in any redistribution

****************************************************/

#include // Core graphics library

#include // Hardware-specific library

#include

// For the breakout, you can use any 2 or 3 pins

// These pins will also work for the 1.8” TFT shield

#define TFT_CS 9

#define TFT_RST 7 // you can also connect this to the Arduino reset

// in which case, set this #define pin to 0!

#define TFT_DC 8

// Option 1 (recommended): must use the hardware SPI pins

// (for UNO thats sclk = 13 and sid = 11) and pin 10 must be

// an output. This is much faster - also required if you want

// to use the microSD card (see the image drawing example)

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

// Option 2: use any pins but a little slower!

#define TFT_SCLK 13 // set these to be whatever pins you like!

#define TFT_MOSI 11 // set these to be whatever pins you like!

//Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);

float p = 3.1415926;

void setup(void) {

Serial.begin(9600);

Serial.print(“Hello! ST7735 TFT Test”);

// Use this initializer if you‘re using a 1.8“ TFT

tft.initR(INITR_BLACKTAB); // initialize a ST7735S chip, black tab

// Use this initializer (uncomment) if you’re using a 1.44” TFT

//tft.initR(INITR_144GREENTAB); // initialize a ST7735S chip, black tab

Serial.println(“Initialized”);

uint16_t time = millis();

tft.fillScreen(ST7735_BLACK);

time = millis() - time;

Serial.println(time, DEC);

delay(500);

// large block of text

tft.fillScreen(ST7735_BLACK);

testdrawtext(5, 45, “theblckwlf presents”, ST7735_WHITE);

delay(2000);

testdrawtext(15, 65, “the microscreen”, ST7735_WHITE);

testdrawtext(10, 75, “1.8in TFT display”, ST7735_WHITE);

delay(4000);

tft.fillScreen(ST7735_BLUE);

tft.setTextSize(2);

tft.fillScreen(ST7735_WHITE);

tft.setTextSize(1);

testdrawtext(5, 65, “start ”, ST7735_BLACK);

testdrawtext(5, 75, “diagnostic test.。.”, ST7735_BLACK);

delay(1000);

tft.fillScreen(ST7735_WHITE);

testdrawScreenData();

delay(3000);

tft.setTextSize(2);

drawTestGrid(10,10);

tft.setCursor(5, 40);

tft.println(“10x10 Grid”);

delay(2000);

tft.setCursor(15, 40);

drawTestGrid(5,5);

tft.println(“5x5 Grid”);

delay(2000);

tft.fillScreen(ST7735_WHITE);

tft.setTextSize(1);

tft.drawPixel(tft.width()/2, tft.height()/2, ST7735_BLACK);

tft.setCursor(15, (tft.height()/2)-15);

tft.print(“Center ”);

tft.print(tft.width()/2);

tft.print(“, ”);

tft.println(tft.height()/2);

tft.drawCircle(tft.width()/2, tft.height()/2, 5, ST7735_BLACK);

delay(2000);

// tft print function!

tftPrintTest();

delay(4000);

// a single pixel

tft.drawPixel(tft.width()/2, tft.height()/2, ST7735_GREEN);

delay(500);

// line draw test

testlines(ST7735_YELLOW);

delay(500);

// optimized lines

testfastlines(ST7735_RED, ST7735_BLUE);

delay(500);

testdrawrects(ST7735_GREEN);

delay(500);

testfillrects(ST7735_YELLOW, ST7735_MAGENTA);

delay(500);

tft.fillScreen(ST7735_BLACK);

testfillcircles(5, ST7735_BLUE);

testdrawcircles(5, ST7735_WHITE);

delay(500);

for (int i=0; i《5; i++){

testroundrects();

}

delay(500);

testtriangles();

delay(500);

mediabuttons();

delay(500);

Serial.println(“done”);

delay(1000);

}

void loop() {

tft.invertDisplay(true);

delay(500);

tft.invertDisplay(false);

delay(500);

}

void testlines(uint16_t color) {

tft.fillScreen(ST7735_BLACK);

for (int16_t x=0; x 《 tft.width(); x+=6) {

tft.drawLine(0, 0, x, tft.height()-1, color);

}

for (int16_t y=0; y 《 tft.height(); y+=6) {

tft.drawLine(0, 0, tft.width()-1, y, color);

}

tft.fillScreen(ST7735_BLACK);

for (int16_t x=0; x 《 tft.width(); x+=6) {

tft.drawLine(tft.width()-1, 0, x, tft.height()-1, color);

}

for (int16_t y=0; y 《 tft.height(); y+=6) {

tft.drawLine(tft.width()-1, 0, 0, y, color);

}

tft.fillScreen(ST7735_BLACK);

for (int16_t x=0; x 《 tft.width(); x+=6) {

tft.drawLine(0, tft.height()-1, x, 0, color);

}

for (int16_t y=0; y 《 tft.height(); y+=6) {

tft.drawLine(0, tft.height()-1, tft.width()-1, y, color);

}

tft.fillScreen(ST7735_BLACK);

for (int16_t x=0; x 《 tft.width(); x+=6) {

tft.drawLine(tft.width()-1, tft.height()-1, x, 0, color);

}

for (int16_t y=0; y 《 tft.height(); y+=6) {

tft.drawLine(tft.width()-1, tft.height()-1, 0, y, color);

}

}

void drawTestGrid(int hor, int vert){

tft.fillScreen(ST7735_WHITE);

//Draw vertical lines

for (int16_t x=0; x 《 tft.width(); x+=vert){

tft.drawFastVLine(x, 0, tft.height(), ST7735_RED);

}

for (int16_t y=0; y 《 tft.height(); y+=hor){

tft.drawFastHLine(0, y, tft.width(), ST7735_BLACK);

}

}

void testdrawtext(int wid, int hei, char *text, uint16_t color) {

tft.setCursor(wid, hei);

tft.setTextColor(color);

tft.setTextWrap(true);

tft.print(text);

}

void testfastlines(uint16_t color1, uint16_t color2) {

tft.fillScreen(ST7735_BLACK);

for (int16_t y=0; y 《 tft.height(); y+=5) {

tft.drawFastHLine(0, y, tft.width(), color1);

}

for (int16_t x=0; x 《 tft.width(); x+=5) {

tft.drawFastVLine(x, 0, tft.height(), color2);

}

}

void testdrawrects(uint16_t color) {

tft.fillScreen(ST7735_BLACK);

for (int16_t x=0; x 《 tft.width(); x+=6) {

tft.drawRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, color);

}

}

void testfillrects(uint16_t color1, uint16_t color2) {

tft.fillScreen(ST7735_BLACK);

for (int16_t x=tft.width()-1; x 》 6; x-=6) {

tft.fillRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, color1);

tft.drawRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, color2);

}

}

void testfillcircles(uint8_t radius, uint16_t color) {

for (int16_t x=radius; x 《 tft.width(); x+=radius*2) {

for (int16_t y=radius; y 《 tft.height(); y+=radius*2) {

tft.fillCircle(x, y, radius, color);

}

}

}

void testdrawcircles(uint8_t radius, uint16_t color) {

for (int16_t x=0; x 《 tft.width()+radius; x+=radius*2) {

for (int16_t y=0; y 《 tft.height()+radius; y+=radius*2) {

tft.drawCircle(x, y, radius, color);

}

}

}

void testtriangles() {

tft.fillScreen(ST7735_BLACK);

int color = 0xF800;

int t;

int w = tft.width()/2;

int x = tft.height()-1;

int y = 0;

int z = tft.width();

for(t = 0 ; t 《= 15; t+=1) {

tft.drawTriangle(w, y, y, x, z, x, color);

x-=4;

y+=4;

z-=4;

color+=100;

}

}

void testroundrects() {

tft.fillScreen(ST7735_BLACK);

int color = 100;

int i;

int t;

for(t = 0 ; t 《= 4; t+=1) {

int x = 0;

int y = 0;

int w = tft.width()-2;

int h = tft.height()-2;

for(i = 0 ; i 《= 16; i+=1) {

tft.drawRoundRect(x, y, w, h, 5, color);

x+=2;

y+=3;

w-=4;

h-=6;

color+=1100;

}

color+=100;

}

}

void testdrawScreenData(){

tft.setCursor(0,20);

tft.println(“Screen Data:”);

tft.print(“Screen Width: ”);

tft.println(tft.width());

tft.print(“Screen Height: ”);

tft.println(tft.height());

}

void testdrawCountdown(){

tft.setTextWrap(true);

tft.fillScreen(ST7735_RED);

tft.setTextColor(ST7735_WHITE);

tft.setTextSize(6);

tft.setCursor(30, 50);

for (int i=10; i》0; i--){

tft.println(i);

delay(1000);

tft.setCursor(50, 50);

tft.fillScreen(ST7735_RED);

}

}

void circlePass(){

tft.fillScreen(ST7735_BLACK);

testfillcircles(5, ST7735_GREEN);

delay(1000);

testfillcircles(4, ST7735_RED);

delay(1000);

testfillcircles(2, ST7735_BLACK);

testfillcircles(3, ST7735_YELLOW);

delay(500);

}

void tftPrintTest() {

tft.setTextWrap(false);

tft.fillScreen(ST7735_BLACK);

tft.setCursor(0, 30);

tft.setTextColor(ST7735_RED);

tft.setTextSize(1);

tft.println(“Hello World!”);

tft.setTextColor(ST7735_YELLOW);

tft.setTextSize(2);

tft.println(“Hello World!”);

tft.setTextColor(ST7735_GREEN);

tft.setTextSize(3);

tft.println(“Hello World!”);

tft.setTextColor(ST7735_BLUE);

tft.setTextSize(4);

tft.print(1234.567);

delay(1500);

tft.setCursor(0, 0);

tft.fillScreen(ST7735_BLACK);

tft.setTextColor(ST7735_WHITE);

tft.setTextSize(0);

tft.println(“Hello World!”);

tft.setTextSize(1);

tft.setTextColor(ST7735_GREEN);

tft.print(p, 6);

tft.println(“ Want pi?”);

tft.println(“ ”);

tft.print(8675309, HEX); // print 8,675,309 out in HEX!

tft.println(“ Print HEX!”);

tft.println(“ ”);

tft.setTextColor(ST7735_WHITE);

tft.println(“Sketch has been”);

tft.println(“running for: ”);

tft.setTextColor(ST7735_MAGENTA);

tft.print(millis() / 1000);

tft.setTextColor(ST7735_WHITE);

tft.print(“ seconds.”);

}

void mediabuttons() {

// play

tft.fillScreen(ST7735_BLACK);

tft.fillRoundRect(25, 10, 78, 60, 8, ST7735_WHITE);

tft.fillTriangle(42, 20, 42, 60, 90, 40, ST7735_RED);

delay(500);

// pause

tft.fillRoundRect(25, 90, 78, 60, 8, ST7735_WHITE);

tft.fillRoundRect(39, 98, 20, 45, 5, ST7735_GREEN);

tft.fillRoundRect(69, 98, 20, 45, 5, ST7735_GREEN);

delay(500);

// play color

tft.fillTriangle(42, 20, 42, 60, 90, 40, ST7735_BLUE);

delay(50);

// pause color

tft.fillRoundRect(39, 98, 20, 45, 5, ST7735_RED);

tft.fillRoundRect(69, 98, 20, 45, 5, ST7735_RED);

// play color

tft.fillTriangle(42, 20, 42, 60, 90, 40, ST7735_GREEN);

}

就这些了。我用于此步骤的视频显示了如果您运行上面的代码,预期的显示效果。

责任编辑:wv

arduino tft 方向_在Arduino上使用1.8英寸TFT显示屏的入门指南相关推荐

  1. arduino 长传出错_请问Arduino IDE在编译时正常,却无法上传且显示找无效库是怎么回事?...

    开发板:"Arduino Nano atmega328p" 警告:库 Mozzi 中的分类 'audio' 不可用.设置为 'Uncategorized' 项目使用了 2750 字 ...

  2. arduino nano 蓝牙_用Arduino玩转掌控板(ESP32):ESP32概述与Arduino软件准备

    前言 近年来,掌控板(英文名:mPython)在创客教育中应用越来越广泛.掌控板集成了 ESP32 高性能双核芯片,具备 WiFi 和蓝牙连接功能,同时在板子上又配置了丰富的传感器,最重要的是它是专门 ...

  3. arduino编码器计数_基于Arduino开发环境的光电编码器检测仪设计方案 - 全文

    0 引言 Arduino是一款基于单片机系统的电子产品开发平台,它的软硬件系统都具有高度的模块化,而且软件系统是完全开源的.其硬件系统也是高度模块化的,在核心控制板的外围有开关量输入/输出模块.各种模 ...

  4. arduino智能闹钟_【Arduino综合项目】小闹钟

    小闹钟项目 在额济纳支教这一年,给孩子们上了很多Arduino开发的课,也带他们完成了几个Arduino综合项目,下面陆续把这些小项目放上来,欢迎围观~~~非科班出身,C语言学的不好,望各路大神批评指 ...

  5. arduino tft 方向_怎样将TFT 1.44与Arduino Nano结合使用

    步骤1:下载所需的库 将以下库添加到Arduino: https://github.com/adafruit/Adafruit- GFX库 https://github.com/adafruit/Ad ...

  6. arduino tft 方向_ESP32在Arduino环境下玩转 LVGL,ESP32移植LVGL详细教程

    微信关注 "DLGG创客DIY"设为"星标",重磅干货,第一时间送达. ❝ 转载自慕容流年 https://me.csdn.net/qq_41868901 ❞ ...

  7. arduino 休眠 节能_优化arduino程序存储空间

    0x00 Abstract 我们一般在开发Arduino的程序时都是根据功能需求来编写代码,当经过测试后程序满足功能需求后就停止开发,剩下的就是只有在功能需求变更或代码中存在bug时才会再次动手修改代 ...

  8. arduino灯光装置_基于Arduino的智能家居灯控系统设计

    &能应用 ------ T X 阵 W S 2 8 1 2 全 彩 灯 带 R X 工 G N D r 0 引言 智能家居的概念虽然已经有了几十年,但进入我国并取 得一定发展还是最近几年的事, ...

  9. arduino灯光装置_用Arduino实现智能控制-夜间感应灯的制作

    教学基本信息 课名 用 Arduino 实现智能控制 - 夜间感应灯的制作 (一个单元两个课时) 是否属于 地方课程或校本课程 否 学科 信息技术 学段 第三学段 年级 初一 授课日期 2 指导思想与 ...

  10. arduino 停止程序_建立Arduino机器人,第五部分:障碍规避

    欢迎阅读教程系列的第五篇文章,其中我正在构建一个基于遥控Arduino的车辆机器人. 这是我到目前为止发表的文章列表: 第一部分:硬件组件 第二部分:Arduino编程 第三部分:组装机器人 第四部分 ...

最新文章

  1. [你必须知道的.NET]第二十一回:认识全面的null
  2. 通过ping命令测试主机与虚拟机之间是否连通
  3. Field EXP_REVENUE
  4. 等压线上怎么画风向_战场上骑兵应该怎么拔刀?从清人佩刀为何总是刀柄向后说起...
  5. 山东大学linux实验报告,山东大学操作系统实验四
  6. GNS3-ENSP对接实验
  7. python docx 复制_python制作单词抽测题(word版)(一)
  8. 一个超级简单的csv读取工具类
  9. 【综述论文】2020年最新深度学习自然语言处理进展综述论文!!!
  10. 获取iOS设备唯一标示
  11. DSP28335学习记录(五)——eCAP、eQEP
  12. Line 167. parse error, unexpected IS, expecting SEMICOLON ISE14.7
  13. AD与DNS集成,且有备份AD与DNS,主AD与DNS坏,备份DNS如何成为主
  14. 计算机应屏后打印不全怎样处理,打印机打印不完整是怎么回事【解决办法】
  15. 计算机的知识体系结构,计算机体系结构知识点
  16. 浴室预约微信小程序的设计与实现
  17. 安卓aab格式加固、签名和安装命令(超简单)
  18. 马薇薇论阴天期盼太阳
  19. CentOS6u9 Oracle11g RAC 搭建部署(八)OGG测试
  20. ICG setup timing violation介绍?

热门文章

  1. 极化相干分解——Cameron分解
  2. AOKP接听震动PHONE.APK修改方法
  3. PLC滤波算法之卡尔曼滤波(kalman Filter)代码+测试
  4. 第一次进入Eclipse MARS2界面后的一些基本设置
  5. 调用百度大脑AI开放平台接口实现java+web的图像识别技术
  6. 5款优秀的免费加密软件
  7. 360企业版退出密码
  8. ubuntu下deactivate matlab的操作
  9. springboot教学工作量管理毕业设计-附源码221541
  10. git两个分支代码合并