欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
基于51單片機+RC522的闖紅燈檢測源碼
[打印本頁]
作者:
清風徐來1
時間:
2018-10-22 21:04
標題:
基于51單片機+RC522的闖紅燈檢測源碼
系統采用51單片機為主控,rc522為檢測裝置,主要是模擬,紅綠燈通過定時器控制,原理就是邏輯判斷,在紅燈時有車(卡)掃過,就會存儲下車牌號,通過液晶顯示車牌,以及紅燈信息,有闖紅燈信息。代碼如下。
單片機源程序如下:
#include "common.h"
#include "RC522.h"
#include "stdio.h"
#include "12864.h"
#define uchar unsigned char
#define uint unsigned int
char serNum[5];
char Old_serNum[5]=0,Card_serNum[20][5]=0,buf[9];
char str[MAX_LEN];
char code DefaultKey[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
int num,flag,i,j,num1=0;
char temp=29,flag0=0,flag1=0,flag2,flag3,aa;
char temp1=1;
void T1_time1(void) interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
aa++;
if(aa==20)
{
aa=0;
temp--;
}
if(flag1==0)
{
if((temp>0)&&(temp<30)) {RED=0;YELLOW=1;GREEN=1;flag=1;}
}
if(flag0==0)
{
if(temp==0)
{
temp=29;
flag1=1;
}
}
if(flag1==1)
{
if((temp>5)&&(temp<30)) {RED=1;YELLOW=1;GREEN=0;flag=0;}
if((temp<=5)&&(temp>=0)) {RED=1;YELLOW=0;GREEN=1;flag=0;}
flag0=1;
if(temp==0)
{
temp=29;
flag1=0;
flag0=0;
}
}
}
void ShowCard_Id()
{
int i;
char *ptr=buf;
for(i=0; i<4; i++,ptr+=2)
{
sprintf(ptr,"%02x",Card_serNum[num1][i]);
buf[8]='\0';
Lcd_Display(1,5,buf);
}
}
void show_card()
{
char card;
card=Card_serNum[num1][0];
switch(card)
{ case 0x25:
Lcd_Display(3,4,"吉A 88888");
break;
case 0x63:
Lcd_Display(3,4,"吉B 66J67");
break;
case 0x96:
Lcd_Display(3,4,"吉C 98889");
break;
case 0x80:
Lcd_Display(3,4,"吉A YIJ88");
break;
case 0x00:
Lcd_Display(3,4,"00 00000 ");
break;
}
}
void InoutHandle()
{
unsigned char state;
unsigned char readBuf[16];
state = PcdRequest(PICC_REQIDL, str);
if(state != MI_OK) return;
state = PcdAnticoll(serNum);
if(state != MI_OK) return;
state = PcdSelect(serNum);
if(state != MI_OK) return;
state = PcdAuthState(PICC_AUTHENT1A, 1, DefaultKey , serNum);
if(state != MI_OK) return;
state = PcdRead(1, readBuf);
if(state != MI_OK) return;
for(j=0;j<5;j++)
{
if(Old_serNum[j]!=serNum[j])
{
flag2=1;
}
}
if(flag2==1)
{
for(j=0;j<5;j++)
{
Old_serNum[j]=serNum[j];
}
Card_serNum[temp1][0]=Old_serNum[0];
Card_serNum[temp1][1]=Old_serNum[1];
Card_serNum[temp1][2]=Old_serNum[2];
Card_serNum[temp1][3]=Old_serNum[3];
temp1++;
if(temp1==20)
{
temp1=0;
}
flag2=0;
}
PcdHalt();
}
void key_stck()
{
key0 = 1;
key1 = 1;
key2 = 1;
key3 = 1;
if( key0 == 0 )
{
delay_10ms(5);
if( key0 == 0 )
{
while(!key0);
if(num1!=0) num1--;
else num1=0;
}
}
if( key1 == 0 )
{
delay_10ms(5);
if( key1 == 0 )
{
while(!key1);
num1++;
if(num1==20)
{
num1=0;
}
}
}
if( key2 == 0 )
{
delay_10ms(5);
if( key2 == 0 )
{
while(!key2);
}
}
if( key3 == 0 )
{
delay_10ms(5);
if( key3 == 0 )
{
while(!key3);
}
}
Lcd_Num_Display(4,1,num1);
Lcd_Display(3,1,"車牌:");
Lcd_Display(2,1,"違章車輛: 臺");
Lcd_Num_Display(2,6,temp1-1);
if(Card_serNum[1][0]!=0)
{
Lcd_Display(1,1,"有違章");
}
if(Card_serNum[1][0]==0)
{
Lcd_Display(1,1,"無違章");
}
show_card();
}
復制代碼
0.png
(38.75 KB, 下載次數: 33)
下載附件
2018-10-22 21:24 上傳
所有資料51hei提供下載:
RFID闖紅燈檢測.zip
(166.88 KB, 下載次數: 26)
2018-10-22 21:04 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
作者:
admin
時間:
2018-10-22 21:25
補全原理圖或者詳細說明一下電路連接即可獲得100+黑幣
作者:
gchq521
時間:
2023-4-7 10:16
沒有原理圖或者仿真圖嗎
作者:
飛起來哈哈哈
時間:
2023-4-9 14:19
啥有用的信息都沒有
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1