当前位置:网站首页>(18) LCD1602 experiment
(18) LCD1602 experiment
2022-07-06 22:26:00 【I love notes】
In this section, we will complete the programming of another display on the MCU , Use LCD1602 LCD to display the characters we want to output , Output "I LOVE MCU" and “MCU LOVE I” These two short strings . Finish us 51 The last simple experiment of single chip microcomputer , After that, you may directly put several simple projects on it , Deepen for 51 Understanding of SCM .
About LCD1602
1602 Liquid crystal is also called LCD1602 Character LCD , It can show 2 Line character information , Each line can show 16 Characters , It is a kind of special used to display letters 、 Numbers 、 Dot matrix liquid crystal module of symbol , Each of us LCD1602 Modules may be different , But their usage is basically the same , stay LCD1602 Contains 80 Bytes of DDRAM, They are used to display characters . The corresponding relationship between the address and the screen is as follows :

Only one 0x00 To 0x0f and 0x40 To 0x4f It is used to display , The rest can only be used for storage , And about the LCD1602 When we write addresses, each address is added correspondingly 0x80 To reach the corresponding address , For example, you should be in 0x00 This address writes a value , So we need to be in 0x80 Write value , It means that every address has one 0x80 The migration , And about the LCD1602 We have some commonly used instructions to control it ,
among (1) Clear screen instruction :0x01, (2) Mode setting instruction , The instruction format is as follows :

among DB1 The meaning is :
0: After writing data, the cursor moves left 1: After writing data, the cursor moves to the right
among DB0 The meaning is :
0: The display does not move after writing data 1: After writing the data, the whole display screen moves to the right by one unit
(3) Display switch control command , The instruction format is as follows :

among DB2 The meaning is :
0: Display function off 1: Display function on
among DB1 The meaning is :
0: No cursor 1: There are cursors
among DB0 The meaning is :
0: The cursor blinks 1: The cursor does not flash
(4) display mode , Our default setting 16*2 Show ,5*7 Lattice ,8 Bit interface , Then our default instruction is 0x38
About hardware

Among them, there are three control interfaces connected with the single chip microcomputer RS,WR,EN, rest D0 To D7 It's a data port , Used to transmit data , The basic timing is as follows
Read status : Input :RS=L,R/W=H, EN = H Output :D0~D7 Status word
We can't read the corresponding data
Write instructions : Input :RS=L, R/W=L, D0~D7= Instruction code ,E= High pulse Output :D0~D7= data
Writing data : Input :RS=H,R/W=L,D0~D7= data ,E= High pulse Output : nothing
As for each reading and writing, we may delay , In fact, we don't need to be so accurate , Because most liquid crystal displays are nanosecond , And our MCU is not so fast , But in order to stabilize the delay , We will still do a short delay .
About software :
ds1602 The main functions of are as follows :
#include "reg52.h"
sbit lcd_en = P2^7;
sbit lcd_rs = P2^6;
sbit lcd_rw = P2^5;
void delay_us(unsigned int xus){
while(xus--);
}
void lcd1602_write(unsigned char dat, int flag){
lcd_en = 0;
lcd_rs = flag;
lcd_rw = 0;
P0 = dat;
delay_us(500);
lcd_en = 1;
delay_us(100);
lcd_en = 0;
}
void lcd1602_init(){
lcd1602_write(0x38, 0);
lcd1602_write(0x0c, 0);
lcd1602_write(0x06, 0);
lcd1602_write(0x01, 0);
lcd1602_write(0x80, 0);
}Its header file is as follows :
#ifndef _LCD1602_H_
#define _LCD1602_H_
#include "reg52.h"
void delay_us(unsigned int xus);
void lcd1602_write(unsigned char dat, int flag);
void lcd1602_init();
#endifIts main function is as follows :
#include <reg52.h>
#include "ds1602.h"
unsigned char table0[] = {"I LOVE MCU"};
unsigned char table1[] = {"MCU LOVE I"};
void main(){
int i;
lcd1602_init();
lcd1602_write(0x80 + 0x03 , 0);
for(i = 0; i < 10;i++){
lcd1602_write(table0[i], 1);
delay_us(100);
}
lcd1602_write(0x80 + 0x40 + 0x03, 0);
for(i = 0;i < 10;i++){
lcd1602_write(table1[i], 1);
delay_us(100);
}
while(1){
}
} 边栏推荐
- 网络基础入门理解
- How do I write Flask's excellent debug log message to a file in production?
- Unity3d Learning Notes 6 - GPU instantiation (1)
- Common sense: what is "preservation" in insurance?
- Force buckle 575 Divide candy
- anaconda安装第三方包
- 十二、启动流程
- Spatial domain and frequency domain image compression of images
- Force deduction question 500, keyboard line, JS implementation
- Report on technological progress and development prospects of solid oxide fuel cells in China (2022 Edition)
猜你喜欢

(十八)LCD1602实验

2020 Bioinformatics | GraphDTA: predicting drug target binding affinity with graph neural networks

Mise en place d'un environnement de développement OP - tee basé sur qemuv8

如何用程序确认当前系统的存储模式?

ResNet-RS:谷歌领衔调优ResNet,性能全面超越EfficientNet系列 | 2021 arxiv
![[sciter]: encapsulate the notification bar component based on sciter](/img/08/a3dd409261054052291e99dd28af11.png)
[sciter]: encapsulate the notification bar component based on sciter

自制J-Flash烧录工具——Qt调用jlinkARM.dll方式

2021 geometry deep learning master Michael Bronstein long article analysis

ZABBIX proxy server and ZABBIX SNMP monitoring

Spatial domain and frequency domain image compression of images
随机推荐
NPDP认证|产品经理如何跨职能/跨团队沟通?
zabbix 代理服务器 与 zabbix-snmp 监控
NetXpert XG2帮您解决“布线安装与维护”难题
做接口测试都测什么?有哪些通用测试点?
MySQL约束的分类、作用及用法
2022年6月国产数据库大事记-墨天轮
Support multiple API versions in flask
基於 QEMUv8 搭建 OP-TEE 開發環境
NPDP certification | how do product managers communicate across functions / teams?
【sdx62】WCN685X将bdwlan.bin和bdwlan.txt相互转化操作方法
extern关键字
微信红包封面小程序源码-后台独立版-带测评积分功能源码
每日一题:力扣:225:用队列实现栈
(十八)LCD1602实验
自制J-Flash烧录工具——Qt调用jlinkARM.dll方式
3DMAX assign face map
AI enterprise multi cloud storage architecture practice | Shenzhen potential technology sharing
Shortcut keys in the terminal
RESNET rs: Google takes the lead in tuning RESNET, and its performance comprehensively surpasses efficientnet series | 2021 arXiv
PVL EDI project case