基于51单片机的控制角度仪设计proteus仿真

仿真电路图:

基于51单片机的控制角度仪设计proteus仿真

部分参考代码:

#include<AT89X51.h>
#define uchar unsigned char
#define uint unsigned int
sbit	A0=P2^7;
sbit	E1=P2^6;
sbit	E2=P2^5;
sbit	RW=P2^4;
sbit	CS=P2^0;
sbit	CLK=P2^1;
sbit	DOUT=P2^2;
#define LCD_DATA P0
uchar code Y1[96]={
0x10,0x10,0xD0,0xFF,0x90,0x10,0x00,0x42,0xE2,0x52,0x4A,0xC6,0x42,0x40,0xC0,0x00,
0x10,0x60,0x02,0x8C,0x20,0x90,0x8E,0x88,0x88,0xFF,0x88,0x88,0x88,0x88,0x80,0x00,
0x00,0x70,0x08,0x08,0x08,0x08,0xF0,0x00,0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,
0x00,0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0xE0,0x10,0x88,0x88,0x90,0x00,0x00,
0x00,0x18,0x08,0x08,0x88,0x68,0x18,0x00,0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,
0x00,0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x10,0x10,0xF8,0x00,0x00,0x00
};
uchar code Y2[96]={
0x04,0x03,0x00,0xFF,0x00,0x23,0x10,0x8C,0x43,0x20,0x18,0x47,0x80,0x40,0x3F,0x00,
0x04,0x04,0x7E,0x01,0x00,0x00,0xFC,0x44,0x44,0x44,0x44,0x44,0xFC,0x00,0x00,0x00,
0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,
0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,0x0F,0x11,0x20,0x20,0x20,0x1F,0x00,
0x00,0x00,0x00,0x3E,0x01,0x00,0x00,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,
0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00	
};
uchar code H1[120]={
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,
0x00,0x00,0x10,0x10,0xF8,0x00,0x00,0x00,
0x00,0x70,0x08,0x08,0x08,0x08,0xF0,0x00,
0x00,0x30,0x08,0x08,0x08,0x88,0x70,0x00,	
0x00,0x00,0x80,0x40,0x30,0xF8,0x00,0x00,
0x00,0xF8,0x88,0x88,0x88,0x08,0x08,0x00,
0x00,0xE0,0x10,0x88,0x88,0x90,0x00,0x00,
0x00,0x18,0x08,0x08,0x88,0x68,0x18,0x00,
0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,
0x00,0xF0,0x08,0x08,0x08,0x10,0xE0,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,
0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x00,
0x00,0x00,0x0C,0x12,0x12,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
uchar code H2[120]={
0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,
0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,
0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,
0x00,0x18,0x20,0x21,0x21,0x22,0x1C,0x00,
0x00,0x06,0x05,0x24,0x24,0x3F,0x24,0x24,
0x00,0x19,0x20,0x20,0x20,0x11,0x0E,0x00,
0x00,0x0F,0x11,0x20,0x20,0x20,0x1F,0x00,
0x00,0x00,0x00,0x3E,0x01,0x00,0x00,0x00,
0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,
0x00,0x01,0x12,0x22,0x22,0x11,0x0F,0x00,	
0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,
0x00,0x19,0x24,0x24,0x12,0x3F,0x20,0x00,
0x00,0x02,0x02,0x02,0x02,0x02,0x02,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};


void delay(unsigned int i)
{
unsigned char k=200; 
while(i>0)
{
i--;
}
}
void OUTMD(uchar i){	//??
   A0=1; //???	//????
   delay(5);
   E1=1;
   delay(10);
   LCD_DATA=i;
   delay(5);
   E1=0;
}

void OUTSD(unsigned char i){	
   A0=1; //???//??//????
   delay(5);
   E2=1;
   delay(10);
   LCD_DATA=i;
   delay(5);
   E2=0;
}

void OUTMI(uchar i){   //??
   A0=0; //???//????
   delay(5);
   E1=1;
   delay(10);
   LCD_DATA=i;
   delay(5);
   E1=0;
}


void OUTSI(unsigned char i){	 
  A0=0; //???//??//????
  delay(5);
  E2=1;
  delay(10);
  LCD_DATA=i;
  delay(5);
  E2=0;
}



void lcdini(void){	//???
   RW=0;
   OUTMI(0XE2);  OUTSI(0XE2);//??
   OUTMI(0XAE);  OUTSI(0XAE);//POWER SAVE ??????,?????
   OUTMI(0XA4);  OUTSI(0XA4);//????
   OUTMI(0XA9);  OUTSI(0XA9);//1/32???
   OUTMI(0XA1);  OUTSI(0XA1);//?????,????
   OUTMI(0XE0);  OUTSI(0XE0);//??-??-???
   OUTMI(0XEE);  OUTSI(0XEE);//???  ???-??-???
   OUTMI(0X00);  OUTMI(0XC0);
   OUTSI(0X00);  OUTSI(0XC0);
   OUTMI(0XAF);  OUTSI(0XAF);//POWER SAVE ??????,?????
}


void SetPage ( uchar page0,uchar page1)
{
OUTMI(0xB8|page1);
OUTSI(0xB8|page0);
}


void SetAddress ( uchar address0,uchar address1)
{
 OUTMI(address1);
 OUTSI(address0); 
}

void PutCharR(uchar ch)
{
OUTSD(ch);
}


void PutCharL(uchar ch)
{
OUTMD(ch);
} 

void clrscr(void)
{
uchar  i;
uchar  page;
for (page=0;page<4;page++)
  {
    SetPage ( page, page);
    SetAddress(0,0);
    for (i=0;i<61;i++)
        {
          PutCharR(0);
          PutCharL(0);
        }
   }
} 


void Draw_wordh (uint d_where, uint x_add, bit layer, uchar width,uchar *p)
{		//???????
  uchar x, address;     //address?????????
  bit window=0;  //window??????
  d_where = d_where*2*width;		  	  	 
  for (x=width;x>0;x--){
   if (x_add>=61) {window=1;address=x_add%61;}
   else address=x_add;
   if(layer==0){ //??????????
     SetPage(0,0);
     SetAddress(address,address);
     if(window==1)PutCharR(p[d_where]);
     else PutCharL(p[d_where]);
		 
   }

链接:https://pan.baidu.com/s/1FoO_O20ooleGzcavlfgT5Q
提取码:1234

上一篇:基于单片机智能教室照明人数统计系统设计


下一篇:设计分享|单片机电压表模拟