|
小白剛學(xué)單片機(jī),自己找一些仿真練習(xí),但看不懂錯(cuò)的問(wèn)題。。麻煩老師傅指導(dǎo)一下
01bd200c1014cfbf8cca61f3d68e079.png (103.48 KB, 下載次數(shù): 61)
下載附件
2021-3-10 11:33 上傳
6f0a3cc0196711fee32abe0b73bdbaa.png (8.9 KB, 下載次數(shù): 58)
下載附件
2021-3-10 11:34 上傳
- #include "reg52.h"
- #define uchar unsigned char
- #define uint usigned int
- sbit K1=P1^0;
- sbit K2=P1^1;
- sbit K3=P1^2;
- sbit K4=P1^3;
- sbit D1=P0^0;
- sbit D2=P0^1;
- sbit D3=P0^2;
- sbit D4=P0^3;
- void delay(uint z)
- {
- uint x,y;
- for(x=z;x>0;x--)
- for(y=110;y>0;y--);
- }
- void main()
- {
- D1=1;D2=1;K3=1;K4=1;
- while(1)
- {
- if(K1!=1,K2!=1)
- {
- D1=0;D2=0;
- }
- else
- {
- D1=1;D2=1;
- }
- if(K3!=1,K4!=1)
- {
- dleay(10);
- if(K3!=1,K4!=1)
- {
- while(K3!=1,K4!=1);
- D3=!D3;D4=!D4;
- }
- }
- }
- }
復(fù)制代碼
|
|