archieve: homework7 test2

This commit is contained in:
2025-05-25 00:13:04 +08:00
parent 1b64a5df5b
commit 3b682e993c
4 changed files with 58 additions and 12 deletions
+36
View File
@@ -0,0 +1,36 @@
/*
* @name: test2.c
* @author: msksbr
* @date: 2025-05-24
* @description: a test for homework7's homework tests
* @version: 1.0
* homework zh_CN: 点阵显示心形图形
* homework EN: display a heart shape on the led matrix
*/
#include "homework7.h"
void test2()
{
unsigned char i; // @var i: a counter for the loop
unsigned char code heart[] = {
0x00, 0x66, 0xFF, 0xFF,
0xFF, 0x7E, 0x3C, 0x18};
// @subsection: display a heart shape on the led matrix
while (1) // @loop: display the heart shape on the led matrix
{
for (i = 8; i > 0; i--) // @loop: display the heart shape on the led matrix
{
switch_138(i); // switch the 74HC138's address to i
P2 = ~heart[i]; // display the heart shape on the led matrix
delay_ms(1);
P2 = 0xFF; // turn off the led matrix
}
i = 8;
}
}
void main()
{
test2();
}