|
如題。傳動(dòng)是用的直流減速電機(jī)帶動(dòng)門上的主軸。,
驅(qū)動(dòng)用的是L9110H芯片。
0.png (65.5 KB, 下載次數(shù): 148)
下載附件
2017-1-7 15:20 上傳
全部代碼下載:
RC522_C51.zip
(63.73 KB, 下載次數(shù): 102)
2016-12-10 21:06 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
主程序:
- #include "lpcreg.h"
- #include "main.h"
- #include "mfrc522.h"
- sbit LED=P0^6;
- sbit LED1=P0^7;
- sbit key=P1^2;
- sbit returnkey=P1^3;
- #define N 6//卡數(shù)量
- unsigned char *g_ucTbuf;
- unsigned char code data1[16] = {0x12,0x34,0x56,0x78,0xED,0xCB,0xA9,0x87,0x12,0x34,0x56,0x78,0x01,0xFE,0x01,0xFE};
- unsigned char code data2[4] = {0x12,0,0,0};
- unsigned char code DefaultKey[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
- unsigned char g_ucTempbuf[20];
- char code *Date[]={"F2B4F51C","126AE91C","9256F41C","1290F41C","961F8141","AA33263B"};//卡ID
- void open_door(void)
- {
- int j,l;
- for(j=0;j<50;j++)
- for(l=0;l<1000;l++);
- LED1=1;
- LED=0;
- for(j=0;j<500;j++)
- for(l=0;l<1000;l++);
- LED=0;
- LED1=0;
- for(j=0;j<1000;j++)
- for(l=0;l<1000;l++);
- LED=1;
- LED1=0;
-
- for(j=0;j<200;j++)
- for(l=0;l<1000;l++);
- LED=0;
- LED1=0;
- }
- void set()
- {
- TMOD=0x20;
- TH1=0x00;
- TH1=0x00;
- IT0=1;
- EX0=1;
- ET1=1;
- EA=1;
- TR1 =1;
- }
- void DelayMs(unsigned int _MS)
- {
- TH0 = (unsigned char)(RCAP2_1ms>>8);
- TL0 = (unsigned char)(RCAP2_1ms);
- ET0 = 0; // Disable timer2 interrupt
- TR0 = 1;
- while (_MS--)
- {
- while (!TF1);
- TF0 = 0;
- TH0 = (unsigned char)(RCAP2_1ms>>8);
- TL0 = (unsigned char)(RCAP2_1ms);
- }
- TR0 = 0;
- }
- void rfidpanduan(void)
- {
- int f;
- unsigned char status,Card[8];
- unsigned char code *ar={"0123456789ABCDEF"};
- status = PcdRequest(PICC_REQALL,g_ucTbuf);
- if (status == MI_OK)
- {
- status = PcdAnticoll(g_ucTempbuf);
- if (status == MI_OK)
- {
-
- status = PcdSelect(g_ucTempbuf);
- if (status == MI_OK)
- {
-
- for(f=0;f<4;f++)
- {
- Card[f*2]=ar[*(g_ucTempbuf+f)/16];
- Card[f*2+1]=ar[*(g_ucTempbuf+f)%16];
- }
- for(f=0;f<N;f++)
- {
- if(Card[0]==Date[f][0]&&Card[1]==Date[f][1]&&Card[2]==Date[f][2]&&Card[3]==Date[f][3]&&Card[4]==Date[f][4]&&Card[5]==Date[f][5]&&Card[6]==Date[f][6]&&Card[7]==Date[f][7])
- {
- open_door();
- break;
- }
- }
- }
- }
- }
- }
- void main( )
- {
- InitializeSystem( );
- PcdReset();
- PcdAntennaOff();
- PcdAntennaOn();
- set();
- M500PcdConfigISOType( 'A' );
- LED=0;
- LED1=0;
- while (1)
- {
- rfidpanduan();
- if(key==0)
- {
- returnkey=1;
- open_door();
- }
- else
- {
- returnkey=0;
- }
- }
- }
- /////////////////////////////////////////////////////////////////////
- //系統(tǒng)初始化
- /////////////////////////////////////////////////////////////////////
- void InitializeSystem()
- {
- P0M1 = 0x0; P0M2 = 0x0;
- P1M1 = 0x0; P1M2 = 0x0;
- P3M1 = 0x0; P3M2 = 0xFF;
- P0 = 0xFF; P1 = 0xFF; P3 = 0xFF;
- }
- /////////////////////////////////////////////////////////////////////
- //用T2做延時(shí)子程序
- /////////////////////////////////////////////////////////////////////
復(fù)制代碼
|
|