1602 LCD Display

Source: Internet
Author: User

#include <reg52.h> #define UCHAR unsigned char#define uint unsigned intsbit rs=p3^5;sbit lcden=p3^4;sbit dula=p2^6; Sbit Wela=p2^7;uchar table1[]= "Tx-51star MCU"; Uchar table2[]= "WWW. Txmcu.com "; void delay (uint x) {uint a,b;for (a=x;a>0;a--) for (b=10;b>0;b--);} void write_com (Uchar com)//some commands, Rs=0{p0=com;rs=0;lcden=0;delay (ten); Lcden=1;delay (ten); lcden=0;} void Write_data (Uchar dat)//write data, Rs=1{p0=dat;rs=1;lcden=0;delay (ten); Lcden=1;delay (ten); lcden=0;}   void Init () {dula=0;wela=0;write_com (0x38);   Display Mode settings: 16x2 display, 5x7 lattice, 8-bit Data interface delay (write_com); 0x0f;   Display Mode setting delay ((); write_com (0x06);   Display Mode settings: The cursor moves right, the character does not move delay ((); write_com (0x01); Clear the screen instruction, clears the previous display content delay (20);}  void Main () {Uchar a;init ();  1602 Initialize write_com (0x80); Set the position of the character you want to display as the first row of the first column a=0;while (table1[a]!= ' s)//As long as you do not write to the end flag, continue to write {//This is the first method of the write character, using the while loop. Write_data (Table1[a]); a++;}  Write_com (0x80+0x40); Sets the position of the second line character display, for the second row, the first column a=0;for (a=0;a<13;a++)//To display a total of 13 characters, so Loop 13 times. {//This is the second method of the write character, with a For loop Write_data (Table2[a]);d Elay (10);} while (1);} 

1602 LCD Display

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.