#include<reg52.h>
/*--------------------------------------------------------------------------------------------------------------------
-----------------±äÁ¿¶¨Òå----------------------
-------------------------------------------------------------------------------------------------------------------*/
#define uchar unsigned char
#define uint unsigned int
sbit key1=P1^0; //¶Ë¿Ú¶¨Òå,Ñ¡Ôñ¹â±êÔÚ¸öλ»òʮλ
sbit key2=P1^1; //¹â±ê´¦µçѹΪ1Êä³ö
sbit key3=P1^2; //¹â±ê´¦µçѹΪ2Êä³ö
sbit key4=P1^3; //È·¶¨Êä³öµçѹ
sbit key03=P2^0; //¹â±ê´¦µçѹΪ3Êä³ö
sbit key04=P2^1; //¹â±ê´¦µçѹΪ4Êä³ö
sbit key05=P2^2;
sbit key06=P2^3;
sbit key07=P2^4;
sbit key08=P2^5;
sbit key09=P2^6; //¹â±ê´¦µçѹΪ9Êä³ö
sbit rs=P1^4;
sbit en=P1^5;
sbit DAC_CS=P3^2;
sbit DAC_WR=P3^6;
sbit ADC_CS=P0^0;
sbit ADC_DI=P0^1;
sbit ADC_DO=P0^2;
uchar code table1[]=" liu do"; //³õʼ»¯ÏÔʾ
uchar code table2[]=" dianya :0.0V "; //³õʼ»¯µçÔ´
uchar s1,s2,keynum,volt;
/*--------------------------------------------------------------------------------------------------------------------
º¯ÊýÈ«³Æ: void delay(uint z)
º¯Êý¹¦ÄÜ: ÑÓʱº¯Êý £¨ºÁÃ뼶£©
Êä È룺unit z
·µ »Ø£º
µ÷Óú¯Êý:
×¢ÒâÊÂÏ
Ìáʾ˵Ã÷£º
-------------------------------------------------------------------------------------------------------------------*/
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
/*--------------------------------------------------------------------------------------------------------------------
º¯ÊýÈ«³Æ: void write_com()
º¯Êý¹¦ÄÜ: дָÁîµ½LCD1602
Êä È룺uchar com
·µ »Ø£º
µ÷Óú¯Êý:
×¢ÒâÊÂÏ
Ìáʾ˵Ã÷£º
-------------------------------------------------------------------------------------------------------------------*/
void write_com(uchar com)
{
rs=0;
en=0;
P0=com;
delay(5);
en=1;
delay(5);
en=0;
}
/*--------------------------------------------------------------------------------------------------------------------
º¯ÊýÈ«³Æ: void write_date()
º¯Êý¹¦ÄÜ: дÊý¾Ýµ½LCD1602
Êä È룺uchar data
·µ »Ø£ºÎÞ
µ÷Óú¯Êý: ÎÞ
×¢ÒâÊÂÏ
Ìáʾ˵Ã÷£º
-------------------------------------------------------------------------------------------------------------------*/
void write_date(uchar date)
{
rs=1;
en=0;
P0=date;
delay(5);
en=1;
delay(5);
en=0;
}
/*--------------------------------------------------------------------------------------------------------------------
º¯ÊýÈ«³Æ: void write_date()
º¯Êý¹¦ÄÜ: lCD1602³õʼ»¯×Ó³ÌÐò
Êä È룺ÎÞ
·µ »Ø£ºÎÞ
µ÷Óú¯Êý: ÎÞ
×¢ÒâÊÂÏ
Ìáʾ˵Ã÷£º
-------------------------------------------------------------------------------------------------------------------*/
void Init()
{
uchar num;
en=0;
write_com(0x38); //ÖõØÖ·
write_com(0x0c);
write_com(0x06); //¹â±êÓÒÒÆ
write_com(0x01); //ÇåÏÔʾ
write_com(0x80); //lcd DDRAMÉèÖÃ
for(num=0;num<16;num++)
{
write_date(table1[num]);
delay(50);
}
write_com(0x80+0x40); //lcdµÚ¶þÐÐ
for(num=0;num<14;num++)
{
write_date(table2[num]);
delay(50);
}
}
/*--------------------------------------------------------------------------------------------------------------------
º¯ÊýÈ«³Æ: void write_voltage()
º¯Êý¹¦ÄÜ: дµçѹµ½lCD1602
Êä È룺uchar add,uchar dat
·µ »Ø£ºÎÞ
µ÷Óú¯Êý: ÎÞ
×¢ÒâÊÂÏ
Ìáʾ˵Ã÷£º
-------------------------------------------------------------------------------------------------------------------*/
void write_voltage(uchar add,uchar dat)
{
write_com(0x80+0x40+add); //È·¶¨µÚ¶þÐÐλÖÃ
write_date(0x30+dat); //дÊý¾Ý
}
/*--------------------------------------------------------------------------------------------------------------------
º¯ÊýÈ«³Æ: void DA0832out()
º¯Êý¹¦ÄÜ: дµçѹÊý¾Ýµ½DAC0832
Êä Èë:char dadata
·µ »Ø£ºÎÞ
µ÷Óú¯Êý: ÎÞ
×¢ÒâÊÂÏ
Ìáʾ˵Ã÷£º
-------------------------------------------------------------------------------------------------------------------*/
void DA0832out(uchar dadata)
{
DAC_CS=0;
P0=dadata;
DAC_WR=0;
delay(5);
DAC_WR=1;
DAC_CS=1;
}
/*--------------------------------------------------------------------------------------------------------------------
º¯ÊýÈ«³Æ: void AD0832out()
º¯Êý¹¦ÄÜ: дµçѹÊý¾Ýµ½ADC0832
Êä Èë:char dadata
·µ »Ø£ºÎÞ
µ÷Óú¯Êý: ÎÞ
×¢ÒâÊÂÏ
Ìáʾ˵Ã÷£º
-------------------------------------------------------------------------------------------------------------------*/
void AD0832out(uchar dadata)
{
ADC_CS=0;
P0=dadata;
ADC_DI=0;
delay(5);
ADC_DO=1;
ADC_CS=1;
}
/*--------------------------------------------------------------------------------------------------------------------
º¯ÊýÈ«³Æ: void keyscan()
º¯Êý¹¦ÄÜ: ¼üÅÌɨÃè×Ó³ÌÐò
Êä Èë:char dadata
·µ »Ø£ºÎÞ
µ÷Óú¯Êý:write_com();write_voltage(); Da0832out();
×¢ÒâÊÂÏ
Ìáʾ˵Ã÷£º
-------------------------------------------------------------------------------------------------------------------*/
void keyscan()
{
if(key1==0)
{
delay(5);
if(key1==0)
{
keynum++;
while(!key1); //°´×¡ÖÃÒ»Ö±µ½·ÅÊÖ
if(keynum==1) //µÈÓÚ 1
{
write_com(0x80+0x40+12);
write_com(0x0f); //ÖÃÊý¾ÝÏÔʾµØÖ·
}
}
if(keynum==2) //deng=2,ce jia 1
{
write_com(0x80+0x40+10); //ÖÃÊý¾ÝÏÔʾµØÖ·
write_com(0x0f);
}
if(keynum==3) //ÈôµÈÓÚ 3,
{
keynum=0;
write_com(0x0c); //²âÎ޹رê
}
}
if(keynum!=0)
{
if(key2==0)
{
delay(5);
if(key2==0)
{
while(!key2);
if(keynum==1)
{
MarcoPage
- 粉丝: 4391
- 资源: 8837
最新资源
- CBT 3847-1999 船用扁圆形焊接钢法兰.pdf
- CBZ 27-1980 船体结构低温焊接.pdf
- CBT 3962-2005 船用焊接异径铜法兰.pdf
- CBZ 258-1989 铝合金船体氩弧焊接工艺规程.pdf
- CBZ 69-1986 铸钢艉柱手工焊接工艺.pdf
- CBZ 66-1987 铜板的焊接.pdf
- CBZ 802-2007 陶质衬垫CO2单面焊焊接工艺.pdf
- CBZ 801-2007 熔嘴电渣焊焊接工艺.pdf
- CBZ39-1987_焊接材料的验收、存放和使用.pdf
- CBZ124-1998_潜艇921A等钢结构焊接技术要求.pdf
- CBZ126-1998潜艇耐压船体可拆板切割、装配和焊接技术要求.pdf
- CECS 330-2013 钢结构焊接热处理技术规程.pdf
- CJT 32-2004 液化石油气钢瓶焊接工艺评定.pdf
- C-HRA-1镍基合金的焊接工艺性能研究.pdf
- CMT焊接在堆焊(包覆)镍基耐蚀合金层中的应用.pdf
- CNG高压储罐焊接制造质量保证.pdf
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈