駕駛員命令 開關狀態
S0 S1
駕駛員未發出命令 0 0
駕駛員發出左轉顯示命令 1 0
駕駛員發出右轉顯示命令 0 1
駕駛員發出汽車故障顯示命令 1 1
1.PNG (67.81 KB, 下載次數: 67)
下載附件
2018-10-31 18:03 上傳
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
0.png (15.22 KB, 下載次數: 64)
下載附件
2018-11-1 00:27 上傳
0.png (11.23 KB, 下載次數: 61)
下載附件
2018-11-1 00:27 上傳
0.png (44.87 KB, 下載次數: 77)
下載附件
2018-11-1 00:27 上傳
單片機源程序如下:
- #include<reg52.h>
- #define uchar unsigned char
- #define uint unsigned int
- sbit S1=P1^0;
- sbit S2=P1^1;
- sbit L1=P1^4;
- sbit L2=P1^5;
- sbit R1=P1^6;
- sbit R2=P1^7;
- void delay(uint x)
- {
- int t;
- while(x--)
- for(t=0;t<125;t++); //延時1ms
-
- }
- void main()
- {
- P1=0X03; //0000 0011
- while(1)
- {
- {
- if (S1==1&&S2==1)
- delay(10);
- if (S1==1&&S2==1) //消抖
- {
- L1=1,L2=1,R1=1,R2=1; //雙閃
- delay(50);
- L1=0,L2=0,R1=0,R2=0;
- delay(50);
- }
- }
- {
- if (S1==1&&S2==0)
- delay(10);
- if (S1==1&&S2==0) //左轉
- {
- L1=1,L2=1,R1=0,R2=0;
- delay(50);
- L1=0,L2=0,R1=0,R2=0;
- delay(50);
- }
- }
- {
- if (S1==0&&S2==1)
- delay(10);
- if (S1==0&&S2==1) //右轉
- {
- L1=0,L2=0,R1=1,R2=1;
- delay(50);
- L1=0,L2=0,R1=0,R2=0;
- delay(50);
- }
- }
-
- {
- if (S1==0&&S2==0)
- delay(10);
- if (S1==0&&S2==0) //正常
- {
- L1=0,L2=0,R1=0,R2=0;
-
- }
- }
- }
- }
復制代碼
所有資料51hei提供下載:
汽車轉向燈單片機.rar
(17.41 KB, 下載次數: 100)
2018-10-31 18:05 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|