- 电路原理图
- 元件清单
- 程序(C语言)
#include<reg51.h>
sbit p3_0=P3^0;
sbit p3_1=P3^1;
sbit p3_2=P3^2;
sbit p3_3=P3^3;
void delay(unsigned char i);
void main()
{
unsigned char ledctr;
P3=0xff;
while(1)
{
ledctr=P3;
switch(ledctr)
{
case 0xff:P1=0x00;break;
case 0xfe:P1=0xff;break;
case 0xfd:P1=0x55;delay(200);P1=0xaa;delay(200);break;
case 0xfb:P1=0xf0;break;
case 0xf7:P1=0x0f;break;
default:;
}
}
}
void delay(unsigned char i)
{
unsigned char j,k;
for(k=0;k<i;k++)
for(j=0;j<255;j++);
}
- 仿真视频