Home > other >  51 single-chip microcomputer and LCD1602 interface circuit and program
51 single-chip microcomputer and LCD1602 interface circuit and program

Time:09-17

A way of working: indirect way of working,

Second, the realization of functions: display "Hope the epidemic will pass soon",

Three, the simulation circuit diagram:


Four, the program source code:
# include

# define LCD1602_DB P0
Sbit LCD1602_RS P1=^ 0;
Sbit LCD1602_RW P1=^ 1;
Sbit LCD1602_E=P1 ^ 5;

Void InitLcd1602 ();
Void LcdWriteCmd unsigned char (CMD);
Void LcdWaitReady ();
Void LcdShowStr (unsigned char x, unsigned char y, unsigned char * STR);
Void LcdWriteDat unsigned char (dat);
Void LcdSetCursor (unsigned char x, unsigned char y);

Void main ()
{
Unsigned char STR []="Hope the eqidemic";//display the string

InitLcd1602 ();//LCD initialization
LcdShowStr (0, 0, STR);//the first line shows the
LcdShowStr (1, 1, "will pass soon");//the second line shows the
While (1);
}

Void InitLcd1602 ()//initialization function
{
X38 LcdWriteCmd (0);//display mode Settings
X0c LcdWriteCmd (0);//display, don't show the cursor
LcdWriteCmd x06 (0);//pointer plus one, the whole screen does not move
LcdWriteCmd (0 x01);//pointer to reset, showing zero
}

Void LcdWriteCmd unsigned char (CMD)//write function
{
LcdWaitReady ();//busy a test
//write instructions
LCD1602_RS=0;
LCD1602_RW=0;
LCD1602_DB=CMD;
LCD1602_E=1;
LCD1602_E=0;
}

Void LcdWaitReady ()
{
Unsigned char sta.

//read state
LCD1602_DB=0 XFF;
LCD1602_RS=0;
LCD1602_RW=1;
Do {
LCD1602_E=1;
The sta=LCD1602_DB;
LCD1602_E=0;//lower can make pin
} while (sta& 0 x80);//whether the highest sta 0
}

Void LcdShowStr (unsigned char x, unsigned char y, unsigned char * STR)//display function
{
LcdSetCursor (x, y);
While (* STR!='\ 0')
{
Str++ LcdWriteDat (*);
}
}

Void LcdWriteDat unsigned char (dat)
{
LcdWaitReady ();
//write data
LCD1602_RS=1;
LCD1602_RW=0;
LCD1602_DB=dat;
LCD1602_E=1;
LCD1602_E=0;
}

Void LcdSetCursor (unsigned char x, unsigned char y)//character display function
{
Unsigned char addr.
If (y==0)
Addr=0 x00 + x;
The else
Addr=0 x40 + x;
LcdWriteCmd (addr | 0 x80);
}

Five problems:

Add 1, Proteus 8 network label? (not draw lines between two components can be connected via the pin network label)

(1) first of all, will lead to a pin short fuses, double-click the next pin place again, then this pin will automatically draw the same lead,


(2) click on the left side of the toolbar 'LBL options, and then press' a ', will pop-up dialog box, (if not to come out, try to uppercase)

'LBL option position:


The pop-up dialog box:


(3) the contents of the String is changed to: net=x # (example: net=P0 #), where the '#' means changing content, count on behalf of the initial value, increment represent incremental,


(4) move the mouse to add tag pins, such as a mouse into a small hand, and appears when you click the box beside the left key, label added successfully,

Click the left picture:


After adding the images:


2, copy of keil4 procedures to the word, annotation garbled words?

The solution:

(1) in the menu bar, select the 'Edit' option,


(2) in the 'Edit' option drop-down menu, click on the 'Configuration' option,


(3) in the 'Configuration' options dialog ENCODING check box, inside set Chinese GB231, click OK,

CodePudding user response:

Write good!
  • Related