网站建设需要的文案,如何理解网络营销环境,怎么制作网站横幅,字体设计作品赏析STC8H8K64U 库函数学习笔记 —— 流水灯 环境说明#xff1a; 芯片#xff1a;STC8H8K64U 软件#xff1a; KeilC51 μVersion V5.38.00STCAI-ISP (V6.94) 库文件说明#xff1a;我将依赖的库文件统一放置到工程下的 lib 目录中#xff0c;所以#xff0c;代码中的包含指…STC8H8K64U 库函数学习笔记 —— 流水灯 环境说明 芯片STC8H8K64U 软件 KeilC51 μVersion V5.38.00STCAI-ISP (V6.94) 库文件说明我将依赖的库文件统一放置到工程下的 lib 目录中所以代码中的包含指令会有 lib/ 的前缀 从左往右依次亮起然后全灭然后从右往左依次亮起再次全灭不断循环代码如下
#include lib/Config.h
#include lib/STC8G_H_GPIO.h
#include lib/STC8G_H_Delay.hstatic int index 0;
static const int INTERVAL 200;
static const int SIZE 8;void GPIO_config() {P2M1 ~GPIO_Pin_7, P2M0 | GPIO_Pin_7; // 设置 P27 为 推挽P2M1 ~GPIO_Pin_6, P2M0 | GPIO_Pin_6; // 设置 P26 为 推挽P1M1 ~GPIO_Pin_5, P2M0 | GPIO_Pin_5; // 设置 P15 为 推挽P1M1 ~GPIO_Pin_4, P2M0 | GPIO_Pin_4; // 设置 P14 为 推挽P2M1 ~GPIO_Pin_3, P2M0 | GPIO_Pin_3; // 设置 P23 为 推挽P2M1 ~GPIO_Pin_2, P2M0 | GPIO_Pin_2; // 设置 P22 为 推挽P2M1 ~GPIO_Pin_1, P2M0 | GPIO_Pin_1; // 设置 P21 为 推挽P2M1 ~GPIO_Pin_0, P2M0 | GPIO_Pin_0; // 设置 P20 为 推挽P4M1 ~GPIO_Pin_5, P4M0 | GPIO_Pin_5; // 设置 P45 为 推挽
}void turnOffAllLed() {P45 0;P27 1, P26 1, P15 1, P14 1;P23 1, P22 1, P21 1, P20 1;
}void marquee(int start, int incr) {turnOffAllLed();delay_ms(INTERVAL);index start;while(index SIZE index -1) {switch(index) {case 0: P27 0; break; case 1: P26 0; break;case 2: P15 0; break; case 3: P14 0; break;case 4: P23 0; break; case 5: P22 0; break;case 6: P21 0; break; case 7: P20 0; break;}index incr;delay_ms(INTERVAL);}turnOffAllLed();
}void main() {GPIO_config();while(1) {marquee(0, 1);marquee(7, -1);}
}