⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcd1.txt

📁 在单片机应用设计中
💻 TXT
字号:
#include <REGX51.H>
#include "LCD1602.h"

#define uchar unsigned char
#define uint unsigned int

uchar *b,*c,*d;
uchar code a[16]={0X30,0X31,0X32,0X33,0X34,0X35,0X36,0X37,0X38,0X39,0X41,0X42,0X43,0X44,0X45,0X46};
//-------------------delay1ms------------------------------//
void Delay1ms(unsigned int count)
{
	unsigned int i,j;
	for(i=0;i<count;i++)
	for(j=0;j<120;j++);
}




//void In(unsigned char *str) 
//{   // int i;                                                         	        	
	//for(i=0; i<16; i++) 
                                      	
		 //*str=B; 
//		 str++;  //加入有效的数字           	
//	*str='\0'; 
//} 



///键盘扫描程序////
keyscan()
{
  uchar h,n,m;
  P1=0xf0;
  if((P1&0Xf0)!=0Xf0)
    { Delay1ms(2);
	  if((P1&0Xf0)!=0Xf0)
	  {  
	  h=P1;
		h=h&0xf0;
	  }
	}
	  P1=0x0f;
   if((P1&0x0f)!=0x0f)
     {Delay1ms(2);
	  if((P1&0x0f)!=0x0f)
	  {
	   n=P1;
	   n=n&0x0f;
	  }
	 }
   m=n|h;
  return(m);
  }
//----------------主函数------------------//
main()
{
	 uchar p;
  uchar c=0x37;
	LCD_Initial();
	GotoXY(0,0);
	Print("WODE LCDccb Test");
   
   // b=&c;
//	In(b);
	while(1)
	{   
	  // In(&T[0]);
		p=keyscan();

	 switch(p)
	{
		case 0x77:
		{	
		 GotoXY(0,1);
		Print("0");
		break;
		}

        case 0x7b:
		{	GotoXY(0,1);
		Print("1");
		break;
		}

	    case 0x7d:
		{	GotoXY(0,1);
		Print("2");
		break;
		}

		case 0x7e:
		{	GotoXY(0,1);
		Print("3");
		break;
		}

		case 0xb7:
		{	GotoXY(0,1);
		Print("4");
		break;
		}

		case 0xbb:
		{	GotoXY(0,1);
		Print("5");
		break;
		}

           case 0xbd:
	   {	GotoXY(0,1);
		Print("6");
		break;
		}

		case 0xbe:
	   {	GotoXY(0,1);
		Print("7");
		break;
		}

		case 0xd7:
	    {	GotoXY(0,1);
		Print("8");
		break;
		}

		case 0xdb:
		{	GotoXY(0,1);
		Print("9");
		break;
		}

		case 0xdd:
		{	GotoXY(0,1);
		Print("a");
		break;
		}

		case 0xde:
	    {	GotoXY(0,1);
		Print("b");
		break;
		}

		case 0xe7:
		{	GotoXY(0,1);
		Print("c");
		break;
		}

		case 0xeb:
	        { GotoXY(0,1);
		Print("d");
		break;
		}

		case 0xed:
		{	GotoXY(0,1);
		Print("e");
		break;
		}


		case 0xee:
		{
			GotoXY(0,1);
		Print("f");
		break;
		}

		default:{break;}
      }
   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -