当前位置:网站首页>Liquid crystal display
Liquid crystal display
2022-07-03 09:56:00 【Yi 761】
#include<reg52.h>
#define DB P0
sbit RS=P2^6;
sbit RW=P2^5;
sbit E=P2^7;
void chushi();
void lcdshow(unsigned char x,unsigned char y,unsigned char *str);
void xiezhiling(unsigned char cmd);
void main()
{
unsigned char str[]="I LOVE U";
chushi();// initial
lcdshow(4,0,str);
lcdshow(1,1,"hello chengdu");
while(1);
}
void chushi()
{
xiezhiling(0x38);
xiezhiling(0x0C);//0000 1DCB D=1 Turn on the display ;D=0 Turn off the display ;C=1 Show cursor ;C=0 Close the cursor ;B=1 The cursor blinks ;B=0 The cursor does not flash
xiezhiling(0x06);//0000 01NS N=1 Pointer plus one ;N=0 Pointer minus one ;S=1,N=1 Move left ;S=1,N=0 Move right ;S=0 Don't move
xiezhiling(0x01);// All pointers are clear 0
}
void jiance()
{
unsigned char sta;
DB=0xFF;// Keep yourself high before reading
RS=0;
RW=1;
do{
E=1;
sta=DB;
E=0;
}while(sta & 0x80);// Check whether the highest bit is 0
}
void xiezhiling(unsigned char cmd)// Write instructions
{
jiance();
RS=0;
RW=0;
E=1;
DB=cmd;
E=0;
}
void lcdwrdat(unsigned char dat)// Writing data
{
jiance();
RS=1;
RW=0;
E=1;
DB=dat;
E=0;
}
void lcdc(unsigned char x,unsigned char y)// Regard LCD as x and y Axis
{
unsigned char addr;
if(y==0)// When y Shaft for 0 when
addr=0x00+x;// first line 00 To 0F
else
addr=0x40+x;// The second line 40 To 4F
xiezhiling(addr|0x80);
}
void lcdshow(unsigned char x,unsigned char y,unsigned char *str)
{
lcdc(x,y);
while(*str!='\0')// Not equal to space
{
lcdwrdat(*str++);// First value at ++,* and ++ The same level is preferred
}
}
边栏推荐
- Development of fire evacuation system
- Project cost management__ Cost management technology__ Article 7 completion performance index (tcpi)
- Nr-prach:prach format and time-frequency domain
- Development of fire power monitoring system
- Oracle database SQL statement execution plan, statement tracking and optimization instance
- An executable binary file contains more than machine instructions
- Design and development of biological instruments
- A lottery like scissors, stone and cloth (C language)
- Project cost management__ Cost management technology__ Article 8 performance review
- 单片机学到什么程度能找到工作,这个标准不好量化
猜你喜欢
单片机学到什么程度能找到工作,这个标准不好量化
要选择那种语言为单片机编写程序呢
[CSDN]C1训练题解析_第二部分_Web基础
Matlab reads hexadecimal numbers and converts them into signed short
[graduation successful] [1] - tour [Student Management Information System]
Of course, the most widely used 8-bit single chip microcomputer is also the single chip microcomputer that beginners are most easy to learn
编程思想比任何都重要,不是比谁多会用几个函数而是比程序的理解
Seven sorting of ten thousand words by hand (code + dynamic diagram demonstration)
Timer and counter of 51 single chip microcomputer
Schematic diagram and connection method of six pin self-locking switch
随机推荐
There is no shortcut to learning and development, and there is almost no situation that you can learn faster by leading the way
Gpiof6, 7, 8 configuration
C language enumeration type
Fundamentals of Electronic Technology (III)_ Chapter 2 principle of amplification circuit__ Crystal triode and field effect triode
Design and development of biological instruments
Convert IP address to int
Successful graduation [3]- blog system update...
万字手撕七大排序(代码+动图演示)
Stm32-hal library learning, using cubemx to generate program framework
JS foundation - prototype prototype chain and macro task / micro task / event mechanism
Assignment to '*' form incompatible pointer type 'linkstack' {aka '*'} problem solving
Uniapp realizes global sharing of wechat applet and custom sharing button style
SSB Introduction (PbCH and DMRs need to be supplemented)
编程思想比任何都重要,不是比谁多会用几个函数而是比程序的理解
PRACH --- originator
Epollet lessons
01仿B站项目业务架构
没有多少人能够最终把自己的兴趣带到大学毕业上
STM32 serial port usart1 routine
应用最广泛的8位单片机当然也是初学者们最容易上手学习的单片机