星期一, 10月 19, 2009

8051 w2


#pragma oe db pw(80) SM SB CD
#include
#include "Delay.h"
main(){
int num = 0;
char State=0;
P2 =0x3f;

for(;num<6;){
Delay1s();
if(State == 1){
P2 <<= 1;
P2 |=0x01;
}
if(State == 0){
P2 >>= 1;
P2 |=0x80;
}

if((P2&0xc0)==0){//0011 1111 + 1100 0000 =0
State= 0;
num++;
}
if((P2&0x03)==0){
State= 1;
num++;
}
}

for(;;);
}

沒有留言: