Microcontroller LCD Experiment 2

Publisher:CuriousMind123Latest update time:2016-04-18 Source: eefocusKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

code show as below:
#include
#include
 
typedef unsigned char BYTE;
typedef unsigned int WORD;
typedef bit BOOL ; 
 
sbit rs = P2^0; //
sbit rw = P2^1;
sbit ep = P2^2;
 
BYTE code dis1[] = {"welcome!"};
BYTE code dis2[] = {"china !!!refuel!"};
 
delay(BYTE ms)
{ // Delay subroutine
BYTE i;
while(ms--)
{
for(i = 0; i< 250; i++)
{
_nop_();
_nop_();
_nop_();
_nop_();
}
}
}
 
BOOL lcd_bz()
{ // Test LCD busy status
BOOL result;
rs = 0;
rw = 1;
ep = 1;
_nop_();
_nop_();
_nop_();
_nop_();
result = (BOOL)(P0 & 0x80);
ep = 0;
return result;
}
 
lcd_wcmd(BYTE cmd)
{ // Write command data to LCD
while(lcd_bz());
rs = 0;
rw = 0;
ep = 0;
_nop_();
_nop_();
P0 = cmd;
_nop_();
_nop_();
_nop_();
_nop_();
ep = 1;
_nop_();
_nop_();
_nop_();
_nop_();
ep = 0;
}
 
lcd_pos(BYTE pos)
{ //Set the display position
lcd_wcmd(pos | 0x80);
}
 
lcd_wdat(BYTE dat)
{ //Write character display data to LCD
while(lcd_bz());
rs = 1;
rw = 0;
ep = 0;
P0 = that;
_nop_();
_nop_();
_nop_();
_nop_();
ep = 1;
_nop_();
_nop_();
_nop_();
_nop_();
ep = 0;
}
 
lcd_init()
{ //LCD initialization settings
lcd_wcmd(0x38); //
delay(1);
lcd_wcmd(0x0c); //
delay(1);
lcd_wcmd(0x06); //
delay(1);
lcd_wcmd(0x01); //Clear the LCD display content
delay(1);
}
 
main()
{
BYTE i;
lcd_init(); // Initialize LCD
delay(10);
lcd_pos(4); // Set the display position to the 5th character in the first line
i = 0;
while(dis1[i] != '\0')
{ // Display the text "welcome!"
lcd_wdat(dis1[i]);
i++;
}
lcd_pos(0x41); // Set the display position to the second character in the second line
i = 0;
while(dis2[i] != '\0')
{
lcd_wdat(dis2[i]); // Display characters
i++;
}
while(1); // 
}

Keywords:MCU Reference address:Microcontroller LCD Experiment 2

Previous article:Use of timer of STC89C52 microcontroller
Next article:Microcontroller LCD Experiment 1

Recommended ReadingLatest update time:2024-11-23 08:05

Design of Decimal Calculator System Based on AT89C51 Single Chip Microcomputer
      introduction       This system uses AT89C51 single-chip microcomputer as the controller to realize the four-digit "+", "-", "*", "/" operation. The operation result is displayed through the digital tube and has a clearing function. AT89C51 has the following features: 40 pins, 4k BytesFlash on-chip program me
[Microcontroller]
Design of Decimal Calculator System Based on AT89C51 Single Chip Microcomputer
51 MCU series - how to write external interrupts (explanation + example: change the pipeline
When I was learning about 51 MCU interrupts, I was often confused by external interrupts, timers/counters, and serial ports. I was originally a primary school student, how could I stand the torture! ! ! I have nothing to do, so I wrote this today to introduce and explain the external interrupts INT0 and INT1. I will
[Microcontroller]
51 MCU series - how to write external interrupts (explanation + example: change the pipeline
Design of broadband DC amplifier based on MSP430F449 single chip microcomputer
  According to the design requirements, the maximum voltage gain ≥ 60dB is achieved within a wide signal bandwidth (0-10MHz), and the ability to continuously adjust the gain or preset the gain in 5dB steps is the biggest difficulty and one of the key points of the design. Another difficulty is that the maximum output
[Microcontroller]
Design of broadband DC amplifier based on MSP430F449 single chip microcomputer
2: The first 51 single-chip microcomputer assembly experiment
An instruction is an instruction that instructs the microcontroller to perform a certain operation. 1. Machine code instructions are expressed in binary (or hexadecimal). This form of instruction can be directly recognized and executed by computer hardware. For example: binary code "0000 0100B", (hexadecimal "04H").
[Microcontroller]
2: The first 51 single-chip microcomputer assembly experiment
In-Application Programming MAXQ Microcontrollers with Erasable Program and Data Partitions
Abstract: This application note describes the program and data flash memory in MAXQ microcontrollers and how to erase/write the flash memory using the built-in application ROM. This application note applies to all MAXQ microcontrollers that use sector-erasable flash memory. introduction This application note d
[Analog Electronics]
In-Application Programming MAXQ Microcontrollers with Erasable Program and Data Partitions
Calculation of accurate timing of the timer of PIC microcontroller
Here, TMR0 of 16C711 microcontroller is used as timer interrupt, hoping to achieve accurate timing. In the program, TMR0 uses the 32-frequency division of the crystal oscillator, and the initial value is #0FCH. Therefore, POPBEAR brothers calculated the timing time of each timer interrupt as (256-X)*32*4/32768=0.01562
[Microcontroller]
PID Water Temperature Control System Based on 51 Single Chip Microcomputer
1. Hardware Solution This design mainly uses the 51 single-chip microcomputer system for temperature acquisition and control; the temperature signal is collected by the digital temperature sensor DS18B20, and the main controller actively obtains the sensor temperature value, calculates it with the set temperature thro
[Microcontroller]
PID Water Temperature Control System Based on 51 Single Chip Microcomputer
Some basic issues of microcontrollers
What do 1T 4T 6T 12T microcontrollers generally refer to? The standard 51 is 12T, which means 12 clock cycles (crystal cycle, for example, 12M, the cycle is 1/12M, unit is second), the machine does an instruction cycle, exactly 1/12M*12=1uS, common instructions such as nop is one cycle, exactly 1uS, most of the othe
[Microcontroller]
Latest Microcontroller Articles
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号