星期二, 10月 13, 2009

8051 led


#pragma oe db pw(80) SM SB CD
#include
#include "Delay.h"
code tbl1[]= { 0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf } ;
int num= 0;

int main()
{
char i ;
int id = 0;
/*P0 =0x01;*/
P0 =0xc0;
/*P0 =0x80;*/

for(num = 0;num<=6;){
Delay100ms() ;
P3 = num;
if((P0&0x3f) == 0){ /*0x01*/
num++;
id = 1;
}
if((P0&0xfc) == 0){ /*0x80*/
num++;
id = 0;
}
if(id == 0){
P0 <<=1 ;
}else{
if(num<6) P0 >>=1 ;
}
}
Delay1s() ;
Delay1s() ;
Delay1s() ;
Delay1s() ;

/*P0 >>=1;*/
/*P0=tbl1[1];*/
/*
for(;;) {
for(i = 0 ; i < 14 ; i++ ){
P0=tbl1[i] ;
Delay100ms() ;
}
}
*/
return 0;

}

沒有留言: