[KeilC51] 俄罗斯方块流水灯
Zhouzhi童鞋的作业,大家的思路差不多。。
1 #include <reg52.h> 2 3 4 void delay(unsigned int var){ 5 while(var--); 6 } 7 void main(){ 8 char idx1,idx2; 9 unsigned char temp_P0 ; 10 unsigned char Onthego ; 11 unsigned char stack; 12 temp_P0 = 0x00; 13 stack = 0x00; 14 for(idx1=7;idx1>=0;idx1--){ 15 Onthego = 0x01; 16 for(idx2=0; idx2<=idx1;idx2++){ 17 temp_P0 = stack; 18 temp_P0 |= Onthego; 19 P0 = ~temp_P0; 20 delay(30000); 21 Onthego *= 2 ; 22 if(idx2+1==idx1){ 23 stack |= Onthego; 24 } 25 } 26 } 27 while(1); 28 }
Keil & Protues 工程文件:
https://files.cnblogs.com/alimy/tetris_Led.zip
~不再更新,都不让我写公式,博客园太拉胯了