欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 科技 > IT业 > 基于Arduino UNO的1.8寸TFT屏幕使用方法(Arduino系列十八)

基于Arduino UNO的1.8寸TFT屏幕使用方法(Arduino系列十八)

2024/10/24 9:43:02 来源:https://blog.csdn.net/LNN0212/article/details/142682956  浏览:    关键词:基于Arduino UNO的1.8寸TFT屏幕使用方法(Arduino系列十八)

目录

1、所需材料

2、模块简介

2.1Arduino UNO

2.2 1.8寸TFT显示屏

3、接口接线

4、代码示例

5、运行结果

6、总结


1、所需材料

Arduino  UNO 开发板 +1.8寸TFT显示屏(驱动ST7735S)+公对母杜邦线三根

2、模块简介

2.1Arduino UNO

Arduino Uno 是一款基于 微控制器 MTATmega328P的开发板。它有14个数字输入/输出引脚(这些引脚中有6个引脚可以作为PWM输出引脚),6个模拟输入引脚,16 MHz石英晶振,USB接口,电源接口,支持在线串行编程以及复位按键。用户只需要将开发板与电脑通过USB接口连接就可以使用。

2.2 1.8寸TFT显示屏

一共有八个针脚

3、接口接线

Arduino UNO1.8寸TFT显示屏
5VVDD
GNDGND
PIN13SCL
PIN11SDA
PIN8RST
PIN9DC
PIN10CS

BLK是背光接口可以不接

4、代码示例

#include <TFT.h>  // Arduino LCD library
#include <SPI.h>// pin definition for the Uno
#define cs   10
#define dc   9
#define rst  8TFT TFTscreen = TFT(cs, dc, rst);// position of the line on screen
int xPos = 0;void setup() {// initialize the serial portSerial.begin(9600);// initialize the displayTFTscreen.begin();// clear the screen with a pretty colorTFTscreen.background(250, 16, 200);
}void loop() {// read the sensor and map it to the screen heightint sensor = analogRead(A0);int drawHeight = map(sensor, 0, 1023, 0, TFTscreen.height());// print out the height to the serial monitorSerial.println(drawHeight);// draw a line in a nice colorTFTscreen.stroke(250, 180, 10);TFTscreen.line(xPos, TFTscreen.height() - drawHeight, xPos, TFTscreen.height());// if the graph has reached the screen edge// erase the screen and start againif (xPos >= 160) {xPos = 0;TFTscreen.background(250, 16, 200);} else {// increment the horizontal position:xPos++;}delay(16);
}

5、运行结果

频幕由白色逐渐出现粉色的色带

6、总结

这个项目需要安装TFT库,建议在arduino ide中安装库的时候安装一个低版本的,要不然可能会出现屏幕白屏不显示信息的情况。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com