Arduino UNO驱动合宙1.8‘TFT SPI屏幕示例演示(含资料包)

news/2025/1/11 4:01:09/

Arduino UNO驱动合宙1.8"TFT SPI屏幕示例演示


  • 效果展示
    在这里插入图片描述
    在这里插入图片描述

驱动参考资料包

  • 来源于:http://www.lcdwiki.com/zh/1.8inch_Arduino_SPI_Module_ST7735S_SKU:MAR1801
  • 资料包中2种驱动方式:模拟SPI和硬件SPI驱动方式

1.8inch Arduino SPI Module ST7735S都是一样的驱动芯片,直接利用该资料中的代码轻松点亮合宙1.8"tff屏幕

http://www.lcdwiki.com/res/Program/Arduino_SPI/1.8inch/Arduino_SPI_ST7735S_MAR1801_V1.0/1.8inch_Arduino_SPI_Module_ST7735S_MAR1801_V1.0.zip

在这里插入图片描述

接线说明

/                       CS     DC   RST  SDA   CLK   VCC   GND    
//Arduino Mega2560&Uno  A5    A3    A4    A2    A1   3.3V    GND

驱动显示演示代码

模拟SPI驱动Demo不需要包含库直接编译。

#define CS   A5
#define RS   A3
#define RESET  A4
#define SDA  A2
#define SCK  A1
//LED 不用接
#define LED  A0   //if you don't need to control the LED pin,you should set it to -1 and set it to 3.3Vvoid Lcd_Writ_Bus(unsigned char d)
{uint8_t val = 0x80;while(val){if(d&val){digitalWrite(SDA,HIGH);}else{digitalWrite(SDA,LOW);}digitalWrite(SCK,LOW);digitalWrite(SCK,HIGH);val >>= 1;}
}void Lcd_Write_Com(unsigned char VH)  
{   *(portOutputRegister(digitalPinToPort(RS))) &=  ~digitalPinToBitMask(RS);//LCD_RS=0;Lcd_Writ_Bus(VH);
}void Lcd_Write_Data(unsigned char VH)
{*(portOutputRegister(digitalPinToPort(RS)))|=  digitalPinToBitMask(RS);//LCD_RS=1;Lcd_Writ_Bus(VH);
}void Lcd_Write_Com_Data(unsigned char com,unsigned char dat)
{Lcd_Write_Com(com);Lcd_Write_Data(dat);
}void Address_set(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2)
{Lcd_Write_Com(0x2a);Lcd_Write_Data(x1>>8);Lcd_Write_Data(x1);Lcd_Write_Data(x2>>8);Lcd_Write_Data(x2);Lcd_Write_Com(0x2b);Lcd_Write_Data(y1>>8);Lcd_Write_Data(y1);Lcd_Write_Data(y2>>8);Lcd_Write_Data(y2);Lcd_Write_Com(0x2c); 							 
}void Lcd_Init(void)
{digitalWrite(RESET,HIGH);delay(5); digitalWrite(RESET,LOW);delay(15);digitalWrite(RESET,HIGH);delay(15);digitalWrite(CS,LOW);  //CSLcd_Write_Com(0x11);delay(120);Lcd_Write_Com(0xB1);  Lcd_Write_Data(0x05); Lcd_Write_Data(0x3C); Lcd_Write_Data(0x3C); Lcd_Write_Com(0xB2);  Lcd_Write_Data(0x05); Lcd_Write_Data(0X3C); Lcd_Write_Data(0X3C); Lcd_Write_Com(0xB3);  Lcd_Write_Data(0x05); Lcd_Write_Data(0x3C); Lcd_Write_Data(0x3C); Lcd_Write_Data(0x05);Lcd_Write_Data(0x3C);Lcd_Write_Data(0x3C);Lcd_Write_Com(0xB4); Lcd_Write_Data(0x03);Lcd_Write_Com(0xC0);  Lcd_Write_Data(0x28); Lcd_Write_Data(0x08);Lcd_Write_Data(0x04);   Lcd_Write_Com(0xC1);  Lcd_Write_Data(0xC0);Lcd_Write_Com(0xC2); Lcd_Write_Data(0x0D); Lcd_Write_Data(0X00); Lcd_Write_Com(0xC3);  Lcd_Write_Data(0x8D); Lcd_Write_Data(0x2A);    Lcd_Write_Com(0xC4);   Lcd_Write_Data(0x8D);   Lcd_Write_Data(0xEE); Lcd_Write_Com(0xC5);   Lcd_Write_Data(0x1A); Lcd_Write_Com(0x17);   Lcd_Write_Data(0x05);   Lcd_Write_Com(0x36);    Lcd_Write_Data(0xD8);  Lcd_Write_Com(0xE0);Lcd_Write_Data(0x03); Lcd_Write_Data(0x22); Lcd_Write_Data(0x07); Lcd_Write_Data(0x0A); Lcd_Write_Data(0x2E); Lcd_Write_Data(0x30); Lcd_Write_Data(0x25); Lcd_Write_Data(0x2A); Lcd_Write_Data(0x28); Lcd_Write_Data(0x26); Lcd_Write_Data(0x2E); Lcd_Write_Data(0x3A); Lcd_Write_Data(0x00); Lcd_Write_Data(0x01); Lcd_Write_Data(0x03);Lcd_Write_Data(0x13); Lcd_Write_Com(0xE1);Lcd_Write_Data(0x04); Lcd_Write_Data(0x16); Lcd_Write_Data(0x06); Lcd_Write_Data(0x0D); Lcd_Write_Data(0x2D); Lcd_Write_Data(0x26); Lcd_Write_Data(0x23); Lcd_Write_Data(0x27); Lcd_Write_Data(0x27); Lcd_Write_Data(0x25); Lcd_Write_Data(0x2D); Lcd_Write_Data(0x3B); Lcd_Write_Data(0x00); Lcd_Write_Data(0x01); Lcd_Write_Data(0x04);Lcd_Write_Data(0x13); Lcd_Write_Com(0x3A);    Lcd_Write_Data(0x05); 			Lcd_Write_Com(0x29); digitalWrite(CS,HIGH);
}void H_line(unsigned int x, unsigned int y, unsigned int l, unsigned int c)                   
{	unsigned int i,j;digitalWrite(CS,LOW);Lcd_Write_Com(0x02c); //write_memory_start//digitalWrite(RS,HIGH);l=l+x;Address_set(x,y,l,y);j=l*2;for(i=1;i<=j;i++){Lcd_Write_Data(c>>8);Lcd_Write_Data(c);}digitalWrite(CS,HIGH);   
}void V_line(unsigned int x, unsigned int y, unsigned int l, unsigned int c)                   
{	unsigned int i,j;digitalWrite(CS,LOW);Lcd_Write_Com(0x02c); //write_memory_start//digitalWrite(RS,HIGH);l=l+y;Address_set(x,y,x,l);j=l*2;for(i=1;i<=j;i++){ Lcd_Write_Data(c>>8);Lcd_Write_Data(c);}digitalWrite(CS,HIGH);   
}void Rect(unsigned int x,unsigned int y,unsigned int w,unsigned int h,unsigned int c)
{H_line(x  , y  , w, c);H_line(x  , y+h, w, c);V_line(x  , y  , h, c);V_line(x+w, y  , h, c);
}void Rectf(unsigned int x,unsigned int y,unsigned int w,unsigned int h,unsigned int c)
{unsigned int i;for(i=0;i<h;i++){H_line(x  , y  , w, c);H_line(x  , y+i, w, c);}
}int RGB(int r,int g,int b)
{return r << 16 | g << 8 | b;
}void LCD_Clear(unsigned int j)                   
{	unsigned int i,m;digitalWrite(CS,LOW);Address_set(0,0,127,159);for(i=0;i<128;i++)for(m=0;m<160;m++){Lcd_Write_Data(j>>8);Lcd_Write_Data(j);}digitalWrite(CS,HIGH);   
}void setup()
{pinMode(A0,OUTPUT);pinMode(A3,OUTPUT);pinMode(A4,OUTPUT);pinMode(A5,OUTPUT);pinMode(A1,OUTPUT);pinMode(A2,OUTPUT);digitalWrite(A0, HIGH);digitalWrite(A3, HIGH);digitalWrite(A4, HIGH);digitalWrite(A5, HIGH);digitalWrite(A1, HIGH);digitalWrite(A2, HIGH);Lcd_Init();}void loop()
{  LCD_Clear(0xf800);LCD_Clear(0x07E0);LCD_Clear(0x001F);LCD_Clear(0x0); for(int i=0;i<300;i++){Rect(random(127),random(159),random(127),random(159),random(65535)); // rectangle at x, y, with, hight, color}//  LCD_Clear(0xf800);
}


http://www.ppmy.cn/news/905190.html

相关文章

linux驱动tft屏幕,Linux2.6.26.5加入TFT-LCD驱动

首先下载内核源码&#xff0c;我这里用的是linux-2.6.26.5的内核源码。本文引用地址&#xff1a;http://www.eepw.com.cn/article/148334.htm (1) 在arch/arm/mach-s3c2410/mach-smdk2410.c里添加头文件&#xff1a; #include (2) 在arch/arm/ plat-s3c24xx / commON-smdk.c文件…

microPython驱动tft屏幕显示中文终极解决方案

microPython驱动tft屏幕显示中文终极解决方案 一、运行效果 二、实现原理 原理同上篇文章一样&#xff0c;用在线汉字取模工具获取点阵的字节信息&#xff0c;通过st7789py.py驱动程序显示出来。 上次的程序只能显示部分汉字&#xff0c;需要显示哪些字自己去在线网站取模&a…

STM32驱动ST7789V2 tft屏幕

一 . 简介 本次教程使用的是1.54寸240*240像素的tft屏幕&#xff0c;其接口协议为SPI协议。在使用的过程中仅需要四根数据即可驱动点亮屏幕。然后硬件使用的是STM32F103C8T6核心板&#xff0c;用的是SPI2。一般购买屏幕的话它们会提供对应的例程&#xff0c;直接拿过来修改即可…

TFT屏幕使用(CUBEMX+SPI)

目 录 1.SPI 2.SPIDMA 1.SPI 使用SPI通信协议的器件有很多&#xff0c;这里以TFT屏驱动为ST7735为例。 设置SPI&#xff0c;因为我使用的是STM32F107ZGT的板子所以我的SPI 速度能达到 42M&#xff0c;还需要设置其它的控制引脚。 引脚设置如下所示。 /*GPIO的宏定义…

OLED TFT屏幕相关

文章目录 0.tft espi1.oled1.1 字体4.2 模拟spi oled4.3 IIC oled 2ips tft 0.tft espi 镜像设置 1.oled 1.1 字体 1206-----1608-------2412 4.2 模拟spi oled 我用阿里云盘分享了「OLED」&#xff0c;你可以不限速下载&#x1f680; 复制这段内容打开「阿里云盘」App 即…

ESP32开发板连接TFT屏幕

前言 esp32连接tft屏幕踩了很多坑&#xff0c;也查阅了很多资料&#xff0c;这里简单总结一下&#xff0c;希望能为像我一样的小白排一下坑。 ESP32的引脚 关于esp32的引脚功能&#xff0c;官方给出的文档写的比较多&#xff0c;官方文档如下&#xff1a; ESP32WROOM32技术指…

树莓派SPI连接TFT屏幕

背景 在我们使用树莓派做开发的时候&#xff0c;有些场景下需要屏幕显示&#xff0c;可以选择HDMI屏幕&#xff0c;也可以选择SPI接口的屏幕。HDMI屏幕驱动简单&#xff0c;即插即用&#xff0c;但是成本高&#xff0c;相比较SPI屏幕硬件成本低&#xff0c;GPIO插座连接方便&a…

面试之可重复读是否可以解决幻读

可重复读&#xff08;repeatable read&#xff09;定义:一个事务执行过程中看到的数据&#xff0c;总是跟这个事务在启动时看到的数据时是一致的。 不过理论上 是会出现幻读的&#xff0c;简单的来说幻读指的是当用户读取某一范围的数据行时&#xff0c;另外一个事务又在该范围…