以下是原程序,但只有8个亮度,希望效果:灯的亮度有100个等级,每1s等级加1,100级时跳到1级亮度,每秒亮1个灯,依次P1^0,p1^1--P1^7,再跳到P1^0。
望大神们帮忙解决,最好附上Keil仿真的电路图。
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code LED[8]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
uchar t,k,m,r,tt;
void main(void)
{
TMOD=0X11;
TH0=(65539-760)/256;
TL0=(65536-760)%256;
TH1 =(65536-46080)/256;
TL1 =(65536-46080)%256;
EA=1;
ET0=1;
ET1=1;
TR0=1;
TR1=1;
k=100;
while(1)
{
}
}
void T0_time() interrupt 1
{
TH0 =(65536-760)/256;
TL0 =(65536-760)%256;
t++;
r++;
if(t>=k)
{
P1=LED[m];
}
else
P1=0XFF;
if(t==100)
{
t=0;
k--;
if(k==0)
k=100;
}
}
void T1_time() interrupt 3
{
TH1=(65536-46080)/256;
TL1=(65536-46080)%256;
tt++;
if(tt==20)
{
tt=0;
m++;
if(m==8)
m=0;
}
}
|