From 48fae403e58cbda7f66e120f9577c6709c0da833 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=A1=E5=9D=82=E6=98=B4?= Date: Tue, 25 Mar 2025 13:22:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=EF=BC=9A=E5=AE=9E=E9=AA=8C?= =?UTF-8?q?=E4=B8=89=20=E7=AC=AC=E4=B8=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- homework3/.eide/eide.json | 3 ++- homework3/src/test3.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 homework3/src/test3.c diff --git a/homework3/.eide/eide.json b/homework3/.eide/eide.json index 8889ee1..cf6ed1b 100644 --- a/homework3/.eide/eide.json +++ b/homework3/.eide/eide.json @@ -19,7 +19,8 @@ "targets": { "Debug": { "excludeList": [ - "src/test1.c" + "src/test1.c", + "src/test2.c" ], "toolchain": "Keil_C51", "compileConfig": { diff --git a/homework3/src/test3.c b/homework3/src/test3.c new file mode 100644 index 0000000..7488930 --- /dev/null +++ b/homework3/src/test3.c @@ -0,0 +1,33 @@ +// test3.c +// 左右流水灯 + +#include "homework3.h" + +unsigned char cnt = 0; + +void test3() +{ + ENLED = 0; + ADDR3 = 1; + ADDR2 = 1; + ADDR1 = 1; + ADDR0 = 0; + + while (true) { + if(cnt < 8) { + P2 = ~(0x01 << cnt); // 左向流水 + } else { + P2 = ~(0x80 >> (cnt-8)); // 右向流水 + } + Delay(20000); + cnt++; + if (cnt >= 16) { // 0-7左移,8-15右移 + cnt = 0; + } + } +} + +void main() +{ + test3(); +} \ No newline at end of file