完成:实验三 第二题
This commit is contained in:
@@ -18,7 +18,9 @@
|
|||||||
},
|
},
|
||||||
"targets": {
|
"targets": {
|
||||||
"Debug": {
|
"Debug": {
|
||||||
"excludeList": [],
|
"excludeList": [
|
||||||
|
"src/test1.c"
|
||||||
|
],
|
||||||
"toolchain": "Keil_C51",
|
"toolchain": "Keil_C51",
|
||||||
"compileConfig": {
|
"compileConfig": {
|
||||||
"options": "null"
|
"options": "null"
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ void test1()
|
|||||||
ADDR0 = 0;
|
ADDR0 = 0;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
P2 = ~(0x80 >> cnt);
|
P2 = ~(0x01 << cnt);
|
||||||
Delay(20000);
|
Delay(20000);
|
||||||
cnt++;
|
cnt++;
|
||||||
if (cnt >= 8) {
|
if (cnt >= 8) {
|
||||||
|
|||||||
@@ -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();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user