ESP8266-Arduino编程实例-Nokia5110显示屏驱动

Nokia5110显示屏驱动

1、Nokia5110介绍

诺基亚 5110 是一款适用于多种应用的基本图形 LCD 屏幕。 它最初旨在用作手机屏幕。

它使用 PCD8544 控制器。 PCD8544 是一款低功耗 CMOS LCD 控制器/驱动器,设计用于驱动 48 行和 84 列的图形显示器。 显示器的所有必要功能都在单个芯片中提供,包括片上生成 LCD 电源和偏置电压,从而实现最少的外部组件和低功耗。 PCD8544 通过串行总线接口连接到微控制器。它可以显示英文、中文甚至图像。

在这里插入图片描述

2、硬件准备

  • ESP8266 NodeMCU开发板一块
  • OLED模块一个
  • 面板板一个
  • 杜邦线若干
  • 数据线一条

硬件接线如下:

在这里插入图片描述

3、软件准备

  • Arduino IDE或VSCode + PlatformIO

在前面的文章中,对如何搭建ESP8266开发环境做了详细的介绍,请参考:

ESP8266 NodeMCU的引脚介绍在前面的文章中做了详细的介绍,请参考:

4、代码实现

本次实例使用到Nokia5110驱动库如下:

1)导入依赖库

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <Arduino.h>

#include <SPI.h>
#include <Adafruit\_GFX.h>
#include <Adafruit\_PCD8544.h>

const int8\_t RST_PIN = D2;
const int8\_t CE_PIN = D1;
const int8\_t DC_PIN = D6;
const int8\_t BL_PIN = D0;

// 创建Nokia5110设备对象
Adafruit_PCD8544 display = Adafruit\_PCD8544(DC_PIN, CE_PIN, RST_PIN);

2)设备初始化及显示

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
void setup() {
Serial.begin(9600);
Serial.println("\n\nWeMos D1 Mini + Nokia 5110 PCD8544 84x48 Monochrome LCD\nUsing Adafruit\_PCD8544 and Adafruit\_GFX libraries\n");

// Turn LCD backlight on
pinMode(BL_PIN, OUTPUT);
digitalWrite(BL_PIN, HIGH);

display.begin();
display.setContrast(60); // Adjust for your display
Serial.println("Show Adafruit logo bitmap");

// Show the Adafruit logo, which is preloaded into the buffer by their library
// display.clearDisplay();
delay(2000);

display.clearDisplay();
display.setTextSize(1);
display.setTextColor(BLACK);
display.setCursor(0,0);
display.println("Hello, world!");
display.display();
Serial.println("You should now see Hello, world! on the display");
}

void loop() {
}

文章来源: https://iotsmart.blog.csdn.net/article/details/127011582