1602LCD liquid crystal reverse display program based on 51 single chip microcomputer

Publisher:SerendipitySoulLatest update time:2012-11-15 Source: 21ic Keywords:AT89S51 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

/*1602LCD demonstration program*/
/*MCU model: AT89S51*/
/*Crystal: 11.0592MHZ*/
/*Author: http://www.51hei.com */ /*Compilation environment: Keil 7.50A*/ /****Include header file*****/ #include #include /******************Port definition can be modified according to your circuit*******/ sbit rs=P3^5; sbit rw=P2^7; sbit cs=P3^4; sbit ep=P3^4;/*****Display data table*******/ unsigned char code dis1[] = {"xu han jun"}; unsigned char code dis2[] = {"best wishes"}; /******************** Function: LCD delay subroutine Input parameter: ms Output parameter: ********************/ void delay(unsigned char ms) { unsigned char i; while(ms--) { for(i = 0; i<250; i++) { _nop_(); _nop_(); _nop_(); _nop_(); } } } /******************** Function: Test LCD busy status Input parameter: Output parameter: result **********************/ bit lcd_bz() { bit result; rs = 0; rw = 1; ep = 1; _nop_(); _nop_(); _nop_(); _nop_(); result = (bit)(P0 & 0x80); ep = 0; return result; } /***************** Function: Write instruction data to LCD subroutine Input parameter: cmd Output parameter: ***************/ void lcd_wcmd(unsigned char cmd) { while(lcd_bz());//Judge whether LCD is busy rs = 0; rw = 0; ep = 0; _nop_(); _nop_(); P0 = cmd; _nop_(); _nop_ () ; _nop_(); _nop_(); ep = 1; _nop_(); _nop_(); _nop_(); _nop_(); ep = 0; } /************************* Function: Set display position subroutine Input parameter: posExit parameter: *************************/ void lcd_pos(unsigned char pos) { lcd_wcmd(pos | 0x80); } /*********************** Function: Write display data to LCD subroutine Input parameter: datExit parameter: ************************/ void lcd_wdat(unsigned char dat) { while(lcd_bz()); //Judge whether LCD is busy rs = 1; rw = 0; ep = 0;






























































































P0 = dat;
_nop_();
_nop_();
_nop_();
_nop_();
ep = 1;
_nop_(); _nop_
();
_nop_();
_nop_();
ep = 0;
}
/**********************
Function: LCD initialization subroutine
Input parameter:
Output parameter:
***********************/
void lcd_init()
{
lcd_wcmd(0x38);
delay(1);
lcd_wcmd(0x0c);
delay(1);
lcd_wcmd(0x01);
delay(1);
lcd_wcmd(0x04);
delay(1);
}
/*****************
Function: Main program
Input parameter:
Output parameter:
********************/
void main(void)
{
unsigned char i;
lcd_init();// Initialize LCD
delay(10);
lcd_pos(0x0E);//Set display position
i = 0;
while(dis1[i] != '\0')
{
lcd_wdat(dis1[i]);//Display character
i++;
}
lcd_pos(0x4E);//Set display position
i = 0;
while(dis2[i] != '\0')
{
lcd_wdat(dis2[i]);//Display character
i++;
}
while(1);
}

Keywords:AT89S51 Reference address:1602LCD liquid crystal reverse display program based on 51 single chip microcomputer

Previous article:Single chip digital voltmeter program based on TLC1549
Next article:Decoding pt2262 wireless remote controller using 51 MCU interrupt method

Recommended ReadingLatest update time:2024-11-16 18:07

Timing counter T0 is used as timing technology
1. Circuit diagram Figure 4.16.1 2. System board hardware connection (1. Connect P1.0-P1.3 in the "MCU System" area to L1-L4 in the "Eight-way LED Indicator Module" area with wires. 3. Programming content (1. Since the interrupt method is used, the interrupt source must have its interrupt entry address. F
[Microcontroller]
Timing counter T0 is used as timing technology
PIC16 MCU LCD1602 Driver PIC16F877A PIC16F887
/* LCD display related */ #define DATA 1 /* LCD writes data to 1 */ #define COM 0 /* LCD write command is 0 */ #define LINE1 0b10000000 #define LINE2 0b11000000 #define LCD_E RD6 #define LCD_RW RD5 #define LCD_RS RD4 void LCD_WRITE_4( unsigned char R1, unsigned char FLAG ); void LCD_WRITE( unsigned char R1
[Microcontroller]
PIC16 MCU LCD1602 Driver PIC16F877A PIC16F887
C51 Programming 20-Application (LCD1602 Display-1)
Looking back at the previous programming tutorials, the first one is the I/O chapter. I/O mainly explains the pin characteristics of I/O and how to control the level input and output of I/O through C51; the second one is the interrupt chapter. The interrupt chapter introduces the necessity of the interrupt system and
[Microcontroller]
C51 Programming 20-Application (LCD1602 Display-1)
Design of LCD1602 driver based on S3C2440
Development target platform: linux -2.6.28+S3C2440+CRAMFS/YAFFS2   Development environment: UBUNTU-9.04+ arm - linux -gcc-3.4.1   This time we need to develop a simple character LCD driver on s3c2440, the details are as follows:   LCD1602 has a total of 16 pins, 3 control signals RS, RW, RE, and 8 data lines DB0~DB7,
[Microcontroller]
Design of PID Temperature Control System Based on AT89S51 Single Chip Microcomputer
  Temperature control technology not only plays a very important role in industrial production, but also plays a vital role in daily life. This paper designs the hardware and software of the system. On the basis of establishing the mathematical model of the temperature control system, the system controller is designed
[Microcontroller]
Design of PID Temperature Control System Based on AT89S51 Single Chip Microcomputer
System expansion structure based on AT89S51
  The AT89S51 microcontroller adopts a bus structure, which makes expansion easy to achieve. The AT89S51 microcontroller system expansion structure is shown in the figure below.      As can be seen from the above figure, system expansion mainly includes memory expansion and I/O interface component expansion. The exter
[Microcontroller]
System expansion structure based on AT89S51
Homemade 51 MCU common header files (LCD1602)
/*-------------------------------------------------------------------------- LCD1602.H The user function is C51. Copyright (c) 1988-2004 Keil Elektronik GmbH sum zhaojun All rights reserved. --------------------------------------------------------------------------*/ #ifndef __LCD1602_H__ #define __LCD1602_H__
[Microcontroller]
Design of AT89S51 microcontroller and 82C55 interface chip
1.Hardware interface circuit The figure below shows the circuit diagram of AT89S51 microcontroller extended by an 82C55. In the figure, 74LS373 is the address latch. P0.1 and P0.0 are connected to the address lines A1 and A0 of 82C55 through 74LS373; P0.7 is connected to the chip select terminal CS through 74LS373, an
[Microcontroller]
Design of AT89S51 microcontroller and 82C55 interface chip
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components
Guess you like

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号