Datasets:
Download 5/5.c from KeLe-open-code/MCU: direct link, hf CLI and curl.
- Browser
- Download file 679 Bytes
-
https://huggingface.co/datasets/KeLe-open-code/MCU/resolve/main/5/5.c
- Command line
-
hf download hf://datasets/KeLe-open-code/MCU/5/5.c
-
curl -L -o 5.c https://huggingface.co/datasets/KeLe-open-code/MCU/resolve/main/5/5.c
679 Bytes
| sbit c4=P3^0; | |
| sbit c3=P3^1; | |
| sbit c2=P3^2; | |
| sbit c1=P3^3; | |
| sbit r1=P3^6; | |
| sbit r2=P3^7; | |
| void delayMs(unsigned int i) | |
| { unsigned char t; | |
| while (i--) | |
| { for(t=0;t<120;t++); } | |
| } | |
| unsigned char sk() | |
| { | |
| unsigned char k=0; | |
| P3=255; | |
| r1=0; | |
| if(c1==0){k=1;} | |
| else if(c2==0){k=2;} | |
| else if(c3==0){k=3;} | |
| else if(c4==0){k=4;} | |
| r1=1; | |
| r2=0; | |
| if(k==0) | |
| { | |
| if(c1==0){k=5;} | |
| else if(c2==0){k=6;} | |
| else if(c3==0){k=7;} | |
| else if(c4==0){k=8;} | |
| } | |
| r2=1; | |
| return k; | |
| } | |
| void main() | |
| { | |
| unsigned char k=0; | |
| P2=255; | |
| while(1) | |
| { | |
| k=sk(); | |
| if(k!=0) | |
| { | |
| delayMs(50); | |
| if(sk()==k) | |
| { | |
| P2=0x00; | |
| P2=255U<<k; | |
| } | |
| } | |
| } | |
| } |