这个是流水灯的显示学习的代码
这个buzz的开关竟然是可以扯下来的 我的天 困扰我多年的蜂鸣器在烧录程序时的异响 终于解决了
辛胜至哉,‘割’以咏志hhhhhhhhhhh
代码如下:
#include "reg52.h"
#include <intrins.h>
sbit HC138_A=P2^5;
sbit HC138_B=P2^6;
sbit HC138_C=P2^7;
void selecthc573(unsigned char channel){
switch(channel){
case 4:
P2=(P2&0x1f)| 0x80;
break;
case 5:
P2=(P2&0x1f)| 0xa0;
break;
case 6:
P2=(P2&0x1f)| 0xc0;
break;
case 7:
P2=(P2&0x1f)| 0xe0;
break;
}
}
void Delay1000ms(void) //@11.0592MHz
{
unsigned char data i, j, k;
_nop_();
_nop_();
i = 43;
j = 6;
k = 203;
do
{
do
{
while (--k);
} while (--j);
} while (--i);
}
void ledrunning(){
unsigned char i=0;
for(i=0;i<3;i++){
P0=0x00;
Delay1000ms();
P0=0xff;
Delay1000ms();
}
for(i=0;i<8;i++){
P0=~(0x01<<i);
Delay1000ms();
}
P0=0x00;
Delay1000ms();
P0=0xff;
Delay1000ms();
}
void main(){
selecthc573(5);
P0=0x00;
selecthc573(4);
P0=0xff;
while(1){
ledrunning();
}
}