📄 复件 main.c
字号:
//-------------------------------------------------------
// 编码电位器检测程序
// 作者:cacliu
// 2007.11.1
//A接P3.1,B接P3.2,C接地,并且A,B端均要接一个104的电容到地
//否则检测过程中将会产生很多的误码
//-------------------------------------------------------
#include <reg51.h>
#include "1602.h"
/*=====================码表========================*/
code char tab[]={0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,
0x38,0x39,0x41,0x42,0x43,0x44,0x45,0x46};
unsigned int counter=0,n=0;
unsigned char DD[2];
void main(void)
{
LcdReset();
IT0 = 1;
EX0 = 1;
EA = 1;
Putstr(3,0,"cac cs3310");
Putstr(3,1,"volume:");
while(1)
{
switch (n)
{
case 0: Putstr(10,1,"mute"); break;
case 63: Putstr(10,1,"max "); break;
default :
DD[2]=n/100;
DD[0]=n-10*DD[1];
DD[1]=(n-100*DD[2])/10;
DispOneChar(10,1,' ');
DispOneChar(13,1,' ');
// if (DD[1]==0)
// {
// DispOneChar(11,1,' ');
// DispOneChar(12,1,tab[DD[0]]);
// }
// else
// {
DispOneChar(11,1,tab[DD[1]]);
DispOneChar(12,1,tab[DD[0]]);
// }
}
}
}
void delay(unsigned char dly)
{
unsigned int x;
while(dly--)
{
x = 50;
while(x--);
}
}
void ISR0() interrupt 0
{
if((P3&0x06) == 0x02)
{
delay(1);
if((P3&0x06) == 0x02)
if(counter==63)
{
counter=63;
}
else
{
counter++;
}
n=counter;
}
else
{
delay(1);
if((P3&0x06) == 0x00)
if(counter==0)
{
counter=0;
}
else
{
counter--;
}
n=counter;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -