哈哈哈~

實在是太簡單了阿

如果可以建表我馬上寫出來給你看

用邏輯方式寫出一個可以循環執行的程式

#include <reg51.h>

#define uchar unsigned char
#define uint unsigned int

void delay(uint time);

int main(){
 uchar p1,p2;
 uchar i,j,k;
 uint c = 0;
 while (1){
  p1 = 0xff;
  p2 = 0xff;
  i = 0xf0;
  j = 0x0f;
  P1 = p1;
  P2 = p2;
  for (c = 1;c < 8;c++){
   p1 >>= 1;
   p2 <<= 1;
   P1 = p1;
   P2 = p2;
   delay(1000);
  }
  for (c = 1;c < 8;c++){
   p1 <<= 1;
   p2 >>= 1;
   P1 = p1;
   P2 = p2;
   delay(1000);
  }
  for (c = 1;c < 9;c++){
   p1 >>= 1,p1 += 0x80;
   p2 <<= 1,p2 += 0x01;
   P1 = p1;
   P2 = p2;
   delay(1000);
  }
  for (c = 1;c < 5;c++){
   i <<= 1;
   j >>= 1;
   k = i|j;
   P1 = P2 = k;
   delay(1000);
  }
  p1 = p2 = 0x00;
  for (c = 1;c < 9;c++){
   p1 <<= 1;
   p1 += 0x01;
   P1 = p1;
   delay(1000);
  }
  for (c = 1;c < 9;c++){
   p2 <<= 1;
   p2 += 0x01;
   P2 = p2;
   delay(1000);
  }
 }
}

void delay(uint time){
wait:
 time--;
 if (time != 0)
  goto wait;
}

 

PS : 實在是太簡單了...

創作者介紹
創作者 喜歡亂搞的世界 的頭像
ffyy99

喜歡亂搞的世界

ffyy99 發表在 痞客邦 留言(0) 人氣( 162 )