Simulation and running of Proteus AT89C51 + lcd1602

Source: Internet
Author: User
Tags 0xc0

1. The module corresponding to lcd1602 in protues is lm016l,

Its control chip is generally hd447780, but some are ks0066, and ks0066 can be compatible with HD44780.

Note that a 1 K resistor is required between V0 and VSS, and some must be adjusted by a 10 k potentiometer.

 

2.1602 pin

3. Proteus simulation

 

 

4: Code

 

1. <br/> // filename: Glocal. h <br/> // latest revise: 2010-07-01 <br/> // by: Alex shoal <br/> // Email: alex.shoal@gmail.com <br/> # define uchar unsigned char <br/> # define uint unsigned int <br/> 2. <br/> // filename: ks0066.h <br/> // latest revise: 2010-07-01 <br/> // by: Alex shoal <br/> // Email: alex.shoal@gmail.com <br/> # define data_port P1 <br/> // ------------------------------------------- <br/> // pin definition <br/> //----- ----------------------------------- <Br/> sbit rs = P2 ^ 0; // data (L)/command (h) Select <br/> sbit lcdrw = P2 ^ 1; // write, low level valid <br/> sbit en = P2 ^ 2; // enables, low level valid <br/> // ========================================== ============< br/> // function declaration <br/> // ----------------------------------------------------------- <br/> void delay_ LCD (char ); <br/> void write_data (char); <br/> void write_com (char); <br/> void LCD _init (); <br/> void delay_ms (char ); <br/> void print_stri Ng (char *); <br/> // functions <br/> // write data functions <br/> // -------------------------------------------------- <br/> void write_data (char dat) {<br/> rs = 1; // data <br/> lcdrw = 0; // write <br/> data_port = dat; // send the data to the P port <br/> delay_ms (5); // when the crystal oscillator is high, the delay is added. <br/> en = 1; <br/> delay_ms (5); // delay when the crystal oscillator is high <br/> en = 0; // disable enabling <br/>}< br/> // ------------------------------------------------ <br/> // write command functions <br/> //------- ----------------------------------- <Br/> void write_com (char com) {<br/> rs = 0; // command <br/> lcdrw = 0; // write <br/> data_port = com; <br/> delay_ms (5); // Add latency when the crystal oscillator is high <br/> en = 1; <br/> delay_ms (5); // delay when the crystal oscillator is high <br/> en = 0; <br/>}< br/> // -------------------------------------------- <br/> // 1602 initialization function <br/> // void LCD _init () <br/> () {<br/> lcdrw = 0; <br/> rs = 0; <br/> write_com (0x36 ); // Set text home address <br/> write_com (0x0f); // display switch, display on, cursor on, blink on. <br/> write_com (0x38); <br/> write_com (0x06); // input set. <br/> write_com (0x01); // screen clear <br/> write_com (0x80); // ddram ad set to 00 H, <br/>}< br/> void print_string (char * Str) {<br/> int I; <br/> for (I = 0; STR [I]! = 0; I ++) <br/>{</P> <p> write_data (STR [I]); <br/>}< br/> // latency <br/> // delay function <br/> // ---------------------------------------------- <br/> void delay_ms (uchar t) {<br/> Int J; <br/> for (; t! = 0; t --) <br/> for (j = 0; j <255; j ++); </P> <p >}< br/> 3. <br/> // latest revise: 2010-07-01 <br/> // by: Alex shoal <br/> // Email: alex.shoal@gmail.com <br/> # include <reg51.h> <br/> # include "Global. H "<br/> # include" ks0066.h "// for LCD 1602 <br/> main () {<br/> LCD _init (); </P> <p> print_string ("Hello world! "); <Br/> write_com (0xc0); // ddram ad set to 00 h, <br/> print_string (" this is Alex! "); <Br/> // write_com (0xc0); // ddram ad set to 00 h, <br/> // print_string (" XXX! "); <Br/> while (1); <br/>}< br/> 

 

5. Simulation results

 

6. Take a photo of the actual operation.

 

7. Other parts of the circuit.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.