【Proteus仿真】51单片机+74HC595流水灯
- 🔖Proteus仿真基础实验 -
使用74HC595制作流水灯
- 🌿Proteus
8.12
平台 - 🌿本实验代码基于VSM Studio,采用SDCC编译器。
- 🎬仿真演示:
📝示例驱动代码
- ✨如果想改变流水灯的效果,可以修改对应的数组和移动方式。
#include <mcs51reg.h>
#include <compiler.h>
typedef unsigned char uchar;
typedef unsigned int uint;
#define LED P2_1
#define ST_CP P2_2
#define DS P2_3
#define SH_CP P2_4
uchar __code LED_BIT[] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
void SendTo595(uchar Data)
{
uchar i=0;
for(i;i<8;i++)
{
SH_CP = 0;
DS=0x80&Data;
Data <<=1;
SH_CP = 1;
NOP();
}
ST_CP = 1;
NOP();
NOP();
}
void delayms(unsigned int ms)
{
unsigned int x, y;
for (y = ms; y > 0; y--) {
for (x = 123; x > 0; x--);
}
}
void main(void)
{
uchar i;
while (1)
{
for(i=0;i<8;i++)
{
ST_CP = 0;
SendTo595(LED_BIT[ i]);
delayms(500);
}
}
}
📚仿真资源
链接: https:
提取码: dcum