#include<reg52.h>
#include<absacc.h>
#define uchar unsigned char
#define uint unsigned int
#define da0832 XBYTE[0x7fff]
sbit key1=P2^0;
sbit key2=P2^1;
sbit key3=P2^2;
sbit key4=P2^3;
sbit key5=P2^4;
sbit key6=P2^5;
uchar aa[6]={125,127,129,131,132,135};//对应DAC0832输出电压的值
uint m;
void delay(char c) /*延时1ms*/
{
char a,b;
for(a=c;a>0;a--)
for(b=110;b>0;b--);
}
void keyscan()/* 按键2进行减1*/
{
if(key1==0)
{
m=aa[0];
}
while(key1==0); //等待按键释放
if(key2==0)
{
m=aa[1];
}
while(key2==0); //等待按键释放
if(key3==0)
{
m=aa[2];
}
while(key3==0); //等待按键释放
if(key4==0)
{
m=aa[3];
}
while(key4==0); //等待按键释放
if(key5==0)
{
m=aa[4];
}
while(key5==0); //等待按键释放
if(key6==0)
{
m=aa[5];
}
while(key6==0); //等待按键释放
}
void main()
{
while(1)
{
keyscan();
da0832=m;
delay(10);
}
}
程序写完以后要用proteus仿真,我对程序又不是完全懂,那个按键我要怎样在里面操作啊,求解 |