完成:实验三 第二题

This commit is contained in:
2025-03-25 13:16:52 +08:00
parent b4a3a188fe
commit a60eec5800
3 changed files with 35 additions and 2 deletions
+3 -1
View File
@@ -18,7 +18,9 @@
},
"targets": {
"Debug": {
"excludeList": [],
"excludeList": [
"src/test1.c"
],
"toolchain": "Keil_C51",
"compileConfig": {
"options": "null"
+1 -1
View File
@@ -13,7 +13,7 @@ void test1()
ADDR0 = 0;
while (true) {
P2 = ~(0x80 >> cnt);
P2 = ~(0x01 << cnt);
Delay(20000);
cnt++;
if (cnt >= 8) {
+31
View File
@@ -0,0 +1,31 @@
// test2.c
// 右向流水灯(流水速度逐渐加快)
#include "homework3.h"
unsigned char cnt = 0;
void test2()
{
ENLED = 0;
ADDR3 = 1;
ADDR2 = 1;
ADDR1 = 1;
ADDR0 = 0;
i = 100000;
while (true) {
P2 = ~(0x80 >> cnt);
Delay(i);
cnt++;
if (cnt >= 8) {
cnt = 0;
}
if (i > 5000) {
i -= 1000;
}
}
}
void main()
{
test2();
}