|
大学单片机实验,自己写的程序,仅供参考
#include<reg51.h>
#include<intrins.h>
#define uint unsigned int
sfr P4=0xC0;
sfr P1M0=0x92;
sfr P1M1=0x91;
sfr P2M0=0x96;
sfr P2M1=0x95;
sbit SW17=P3^2;
sbit LED9=P4^7;
sbit LED10=P4^6;
sbit LED8=P1^6;
sbit LED4=P2^7;
sbit LED7=P1^7;
uchar flag=0;
void delay(uint k)
{
uint i,j;
for(i=0;i<k;i++)
{
for(j=0;j<1210;j++)
{;}
}
}
void x0_isr()interrupt 0
{
flag=1;
}
void main()
{
P1M0=00;
P1M1=00;
P2M1=00;
P2M0=00;
if(flag==1)
{while(1)
{
LED9=0;
LED10=1;
LED8=1;
LED4=1;
LED7=1;
delay(1000);
LED9=1;
LED10=0;
LED8=0;
LED4=1;
LED7=1;
delay(1000);
LED9=1;
LED10=1;
LED8=1;
LED4=0;
LED7=0;
delay(1000);
}
}
}
|
|