https://static.assets-stash.eet-china.com/album/old-resources/2009/5/14/63db0e03-8f52-49eb-a1f9-7399816c7c24.rar#include <reg51.h>
sbit s0=P3^0;
sbit s1=P3^1;
sbit s2=P3^2;
#define N 253
void delay (int m)
{
unsigned char i,j,k;
for (i=0;i<m;i++)
for (k=0;k<5;k++)
for (j=0;j<253;j++);
}
void zuozhuan ()
{
P2=0xfb;
delay (N);
P2=0xfd;
delay (N);
P2=0xfe;
delay (N);
}
void youzhuan ()
{
P2=0xf7;
delay (N);
P2=0xef;
delay (N);
P2=0xdf;
delay (N);
}
void chache ()
{
P2=0xff;
delay (N);
P2=0x00;
delay (N);
}
void main ()
{
P2=0xff;
while (1)
{
if (s0==0)
{
delay (2);
if (s0==0)
zuozhuan ();
}
if (s1==0)
{
delay (2);
if (s1==0)
youzhuan ();
}
if (s2==0)
{
delay (2);
if (s2==0)
chache ();
}
}
}
文章评论(0条评论)
登录后参与讨论