51 MCU drives 1602 LCD display c program

Publisher:晴天7777Latest update time:2012-11-24 Source: 21IC Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
/*
Program effect: The single-chip microcomputer controls the LCD display 1602 to display letters and numbers, and the user can change the io
program copyright: http://www.51hei.com
*/
#include //header file
#define uchar unsigned char //macro definition
#define uint unsigned int
uchar code table[]="51HEI XING XING " ; //displayed letters
uchar code table1[]="51HEI MCU XUE YUAU" ;
sbit lcdrs=P1^0; //register selection pin
sbit lcdwr=P1^1; //read and write pin
sbit lcde=P1^2; //chip select pin
void delay(uchar x) //delay sub-function
{
uchar i,j;
for(i=x;i>0;i--)
for(j=110;j>0;j--);
}
void write_com(uchar com) //write instruction sub-function
{ //Write according to 1602 LCD display protocol
P2=com;
lcdrs=0;
lcdwr=0;
delay(5);
lcde=0;
delay(5);
lcde=1;
}
void write_dat(uchar dat) //Write data sub-function
{
P2=dat;
lcdrs=1;
lcdwr=0;
delay(5);
lcde=0;
delay(5);
lcde=1;
}
void init() //Initialization sub-function
{
write_com(0x01); //Clear screen
write_com(0x3f); //Function setting
write_com(0x0d); //Display control
write_com(0x06); //Input mode setting
}
void main()
{
uchar i; //Define local variables
init();
write_com(0x80+0x02+0x10); //Pointer position
for(i=0;i<15;i++) //Display
{
write_dat(table[i]);
delay(50); //Delay, used to adjust speed mismatch
}
write_com(0x80+0x40+0x10);
for(i=0;i<16;i++)
{
write_dat(table1[i]);
delay(50);
}
for(i=0;i<16;i++)
{
write_com(0x18);
delay(50);
}
while(1);
}
Reference address:51 MCU drives 1602 LCD display c program

Previous article:Program to scan keyboard using microcontroller interrupt
Next article:Calculation of accurate delay value in single chip microcomputer C language

Recommended ReadingLatest update time:2024-11-16 16:03

51 MCU: Use timer and LCD1602 to make a simple clock
#include "regx52.h" #include "LCD1602.h" void Delay(int time) {     while(time--) //while loop takes 10us     {     } }  void Timer0Init(void) //1 millisecond @ 11.0592MHz {     TMOD &= 0xF0; //Set timer mode     TMOD |= 0x01; //Set timer mode     TL0 = 0x66; //Set the initial timing value     TH0 = 0xFC; //Set
[Microcontroller]
51 MCU: Use timer and LCD1602 to make a simple clock
pic MCU DS18B20 sampling LCD1602 display
#include "1602.h"  #include "18b20.h"  #include "main.h"  __CONFIG(0X0B31);  main()  {      char msg  = {"  Temperature:  ","              .C"};     delay_us2 (40, 40);      delay_us2 (100, 200);      initial();      while(1) {          start_convert();          change_to_ascii (get_temp (), &msg );              displ
[Microcontroller]
Universal 51 MCU LCD1602 driver
File: lcd_1602.h #ifndef _LCD1602_TRAVELER_H_ #define _LCD1602_TRAVELER_H_ /*****************************Items to be configured*******************************/ #define DATA_LCD P0 //LCD and MCU data port sbit RS_LCD = P2^5; // Connection of RS, RW, E terminals of LCD on MCU side sbit RW_LCD = P2^6; sbit
[Microcontroller]
LCD1602 LCD display module single chip microcomputer driver in-depth explanation of the hardware
(This article is based on the LCD1602 of the HD44780 main control chip. The screenshots are also from the HD44780 data sheet. Users can search for its datasheet by themselves. Some of it is sorted out online, but it is definitely much more in-depth than what you see) 1. Interface  LCD1602 is a character LCD display
[Microcontroller]
LCD1602 LCD display module single chip microcomputer driver in-depth explanation of the hardware
Use 3 IO ports of single-chip microcomputer + 74HC595 driver to control LCD1602 liquid crystal
This content is quite deep and is not recommended for beginners. I have been studying the digital tube driver chip 74HC595 recently and found something very interesting, that is When using 74HC595 as a driver debugging program, I found that it can only output but not input. After searching a lot of information,
[Microcontroller]
Use 3 IO ports of single-chip microcomputer + 74HC595 driver to control LCD1602 liquid crystal
LCD1602 Program Download (AVR)
.include "8515def.inc" .equ rs=0 .equ rw=1 .equ en=2 .org $000  rjmp reset reset: .org $010  ldi r16,low(ramend)  ldi r17,high(ramend)  out spl,r16  out sph,r17 main:  ser r16  out ddra,r16  out porta,r16  out ddrc,r16  out portc,r16    rcall  LCD Ini    ldi r16,$84  rcall WrOp    ldi r16,'a'  rcall WrDat    ldi r16,'
[Microcontroller]
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

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号