高手帮忙下,想将常亮的LED变成闪烁的,请问程序要怎么编.
问题补充:我是初学者,这个程序是7个按钮分别控制7个LED,一个总按钮做RESET用,但我只会用按钮把LED点亮,但我想要闪烁的效果,望高手们指教,不胜感激,程序如下!#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit led1=P0^0;
sbit led2=P0^1;
sbit led3=P0^2;
sbit led4=P0^3;
sbit led5=P0^4;
sbit led6=P0^5;
sbit led7=P0^6;
sbit key1=P2^0;
sbit key2=P2^1;
sbit key3=P2^2;
sbit key4=P2^3;
sbit key5=P2^4;
sbit key6=P2^5;
sbit key7=P2^6;
sbit reset_k=P2^7;
uchar numt0,num;
void delayms(uint xms)
{
uint i,j;
for(i=xms;i>0;i--)
for(j=110;j>0;j--);
}
void init()
{
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-5000)%256;
EA=1;
ET0=1;
TR0=1;
}
void T0_timer()interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
numt0++;
}
void keyscan()
{
if(key1==0)
{
delayms(10);
if(key1==0)
{
led1=0;
while(!key1);
}
}
if(key2==0)
{
delayms(10);
if(key2==0)
{
led2=0;
while(!key2);
}
}
if(key3==0)
{
delayms(10);
if(key3==0)
{
led3=0;
while(!key3);
}
}
if(key4==0)
{
delayms(10);
if(key4==0)
{
led4=0;
while(!key4);
}
}
if(key5==0)
{
delayms(10);
if(key5==0)
{
led5=0;
while(!key5);
}
}
if(key6==0)
{
delayms(10);
if(key6==0)
{
led6=0;
while(!key6);
}
}
if(key7==0)
{
delayms(10);
if(key7==0)
{
led7=0;
while(!key7);
}
}
if(reset_k==0)
{
delayms(10);
if(reset_k==0)
{
led1=1;
led2=1;
led3=1;
led4=1;
led5=1;
led6=1;
led7=1;
while(!reset_k);
}
}
}
void main()
{
init();
while(1)
{
keyscan();
}
}