2020年6月26日 星期五

test

#include <at89x52.h>
char table[]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
char table1[]={0x81,0x42,0x24,0x18,0x24,0x42};
sbit btn1=P2^0;
sbit btn2=P2^1;
sbit dip_sw1=P0^0;
int k=-1;
void delay_1ms(int k)
{
int i,j;
for(i=0;i<k;i++)
for(j=0;j<114;j++)
     ;
}
void ex0_int(void) interrupt 1
{
int i;
P1=0xFF;
for(i=0;i<10;i++)
{
P1=P1^0xFF;
delay_1ms(500);
}
}
main()
{
IE=0x81;
TCON=0x01;
while(1)
{
if(btn1==0)
{
delay_1ms(20);while(btn1!=1);delay_1ms(20);
k=k+1;
if(k>7)
k=0;
}
if(btn2==0)
{
delay_1ms(20);while(btn2!=1);delay_1ms(20);
k=k-1;
if(k<0)
k=7;
}
if(dip_sw1==0)
{
int i;
delay_1ms(20);while(dip_sw1==1);delay_1ms(20);
for(i=0;i<6;i++)
{
P1=~table1[i];delay_1ms(1000);
}
}
if(k==0){P1=~table[k];}
if(k==1){P1=~table[k];}
if(k==2){P1=~table[k];}
if(k==3){P1=~table[k];}
if(k==4){P1=~table[k];}
if(k==5){P1=~table[k];}
if(k==6){P1=~table[k];}
if(k==7){P1=~table[k];}
}
}

沒有留言:

張貼留言

algorithm

 #include <iostream> #include <string.h> using namespace std; int main(int argc, char** argv)  { for(int j=2;j<=100;j++)//j...