#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)
{
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
DC-current-main.zip (52个子文件)
DC-current-main
.DS_Store 6KB
电源
.DS_Store 6KB
dianyuanyangben.c 3KB
备份.txt 17KB
lcd.c 6KB
a60.uvproj 14KB
jjoo;.uvoptx 5KB
dianyuan.uvproj 14KB
电源.pdsprj.LAPTOP-6GFGI1HE.刘航宇.workspace 4KB
Objects
dianyuan.obj 8KB
dianyuan 9KB
dianyuan.build_log.htm 937B
dianyuan.lnp 96B
dianyuan.hex 3KB
a60.hex 2KB
dianyuan.d 583B
STARTUP.obj 828B
dianyuan.crf 229KB
dianyuanold.obj 9KB
a60.build_log.htm 1KB
dianyuan.__i 331B
a60.lnp 117B
a60 8KB
lcd.obj 11KB
Backup Of 电源.pdsbak 37KB
dianyuan.c 5KB
STARTUP.A51 6KB
Last Loaded 电源.pdsbak 37KB
Listings
a60.m51 13KB
lcd.lst 10KB
dianyuanold.lst 9KB
dianyuan.m51 11KB
dianyuan.lst 9KB
STARTUP.lst 14KB
dianyuan.uvopt 5KB
stm32f10x.h 579KB
stm32.uvprojx 14KB
sfwff.uvprojx 13KB
dianyuan.uvgui.刘航宇 88KB
stm32.uvoptx 6KB
dianyuanold.c 5KB
电源.pdsprj.刘航宇的电脑.刘航宇.workspace 873B
dianyuan.uvgui.shu 87KB
电源.pdsprj.DESKTOP-P1GGUT2.shu.workspace 23KB
a60.uvopt 5KB
sfwff.uvguix.刘航宇 87KB
sfwff.uvoptx 5KB
jjoo;.uvprojx 13KB
电源.pdsprj 37KB
jjoo;.uvguix.刘航宇 87KB
stm32.uvguix.刘航宇 89KB
a60.uvgui.刘航宇 88KB
共 52 条
- 1
资源评论
MarcoPage
- 粉丝: 4303
- 资源: 8839
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功