Demo entry 4104034

1602

   

Submitted by anonymous on Mar 20, 2016 at 06:05
Language: C. Code size: 990 Bytes.

#include <reg52.h>

sbit RS = P0^2;
sbit RW = P0^1;
sbit OE = P0^0;

unsigned char name[]="WANZULIANG";

void delayms(unsigned int ms)
{
	unsigned int x,y;
	for( x = 0; x < ms; x++ )
		for( y = 0; y < 121; y++)
		;
}

void COM_Wirte(unsigned char com)
{
	RS = 0;
	RW = 0;
	OE = 0;
	P2= com;
	delayms(1);
	OE = 1;
	delayms(1);
	OE = 0;
}

void DAT_Wirte(unsigned char dat)
{
	RS = 1;
	RW = 0;
	OE = 0;
	P2= dat;
	delayms(1);
	OE = 1;
	delayms(1);
	OE = 0;
}

void Init_1602(void)
{
	COM_Wirte(0x38);
	COM_Wirte(0x0C);//开显示,关闭光标,光标不闪烁
	COM_Wirte(0x06);
	COM_Wirte(0x01);//清屏指令
	delayms(10);		 //等待清屏
}

void DAT_1602(void)
{
	unsigned char i;
	COM_Wirte(0x80);
	DAT_Wirte(0xC0);
	DAT_Wirte(0xB2);
	DAT_Wirte(0xBD);
	DAT_Wirte(0xB7);
	DAT_Wirte(' ');
	for(i=0; i<sizeof(name)-1; i++)
	{
		DAT_Wirte(name[i]);
	}
}

void main (void)
{
	Init_1602();
	while(1)
	{
		
		DAT_1602();	
	}
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).