Datasets:
Download test/probe5/5.c from KeLe-open-code/MCU: direct link, hf CLI and curl.
- Browser
- Download file 1.23 kB
-
https://huggingface.co/datasets/KeLe-open-code/MCU/resolve/main/test/probe5/5.c
- Command line
-
hf download hf://datasets/KeLe-open-code/MCU/test/probe5/5.c
-
curl -L -o 5.c https://huggingface.co/datasets/KeLe-open-code/MCU/resolve/main/test/probe5/5.c
1.23 kB
| /* ���н� P3.6��P3.7�����д����ҽ� P3.3��P3.2��P3.1��P3.0 */ | |
| sbit row1 = P3^7; | |
| sbit row2 = P3^6; | |
| sbit col1 = P3^3; | |
| sbit col2 = P3^2; | |
| sbit col3 = P3^1; | |
| sbit col4 = P3^0; | |
| void delayMs(unsigned int i) | |
| { | |
| unsigned char t; | |
| while (i--) | |
| for (t = 0; t < 120; t++); | |
| } | |
| unsigned char scanKey(void) | |
| { | |
| unsigned char key = 0; | |
| P3 = 255; /* ����������д 1 */ | |
| row1 = 0; /* ɨ���һ�� */ | |
| if (col1 == 0) key = 1; | |
| else if (col2 == 0) key = 2; | |
| else if (col3 == 0) key = 3; | |
| else if (col4 == 0) key = 4; | |
| row1 = 1; | |
| row2 = 0; /* ɨ��ڶ��� */ | |
| if (key == 0) | |
| { | |
| if (col1 == 0) key = 5; | |
| else if (col2 == 0) key = 6; | |
| else if (col3 == 0) key = 7; | |
| else if (col4 == 0) key = 8; | |
| } | |
| row2 = 1; | |
| return key; /* û�а������� 0 */ | |
| } | |
| void main(void) | |
| { | |
| unsigned char key; | |
| P2 = 255; /* LED �͵�ƽ��������ʼȫ�� */ | |
| while (1) | |
| { | |
| key = scanKey(); | |
| if (key != 0) | |
| { | |
| delayMs(20); /* �������� */ | |
| if (scanKey() == key) | |
| P2 = 255U << key; /* ��λ�� 0��������Ӧ�����ĵ� */ | |
| } | |
| } | |
| } | |