Locker Security Sytem Using Humun Detect Sensor and OTP Throuhgt Bluettoth
Locker Security System Using Human Detect Sensor and OTP Through Bluetooth
Protocols: UART, RTC
Brief: We are providing locker security system using human detect sensor will detect a particular person will match then it will generate random OTP that send to whatever device connected to locker Bluetooth then whatever received OTP again enter correctly in particular time if any you do not enter or incorrect OTP locker will not open and again new OTP generated after particular time(1 min).
Hardware Used: lpc2129 development board (ARM7), Bluetooth module HC-05, human detect sensor.
Software Used: Keil µVision 4, Flash Magic
code for the above project
#include<lpc21xx.h>
#include<string.h>
#include<stdlib.h>
void delay(int count)
{
int i,j;
for(i=0;i<count;i++)
{
for(j=0;j<3000;j++)
{
}
}
}
void init_rtc()
{
CCR=(1<<0); // enable
PREINT=456; // crystel oscillator giving 15Mhz, but rtc will work at 32.768khz to scle this we are using formula and geting this number
PREFRAC=25024;
HOUR=12;
ALHOUR=12;
ALMIN=12;
MIN=11;
SEC=0;
}
{
CCR=(1<<0); // enable
PREINT=456; // crystel oscillator giving 15Mhz, but rtc will work at 32.768khz to scle this we are using formula and geting this number
PREFRAC=25024;
HOUR=12;
ALHOUR=12;
ALMIN=12;
MIN=11;
SEC=0;
}
int adc()
{
int result;
PINSEL1 |=(1<<24); //pin configuration
PINSEL1 &= ~(1<<25);
ADCR=(1<<1) | (3<<8)| (1<<16) | (1<<21); //adc configuration
while(1)
{
while(!(ADDR & (1<<31))); //if addr bit 1 then
result=ADDR & (0x3ff<<6); //read the result
result=result>>6; //then shift back
delay(1000);
break;
}
return result;
}
{
int result;
PINSEL1 |=(1<<24); //pin configuration
PINSEL1 &= ~(1<<25);
ADCR=(1<<1) | (3<<8)| (1<<16) | (1<<21); //adc configuration
while(1)
{
while(!(ADDR & (1<<31))); //if addr bit 1 then
result=ADDR & (0x3ff<<6); //read the result
result=result>>6; //then shift back
delay(1000);
break;
}
return result;
}
void uart_int(void)
{
PINSEL0 |= (1<<0)|(1<<2); // configuring the UART funtion
PINSEL0 &= ~((1<<1)|(1<<3));
U0LCR = (1<<0)|(1<<1)|(1<<7); // configuring line control register(LCR),DLATCH
U0DLM = 0; // Loding value DLM and DLL
U0DLL = 97;
U0LCR = (1<<0)|(1<<1); // disable the DLATCH register
}
{
PINSEL0 |= (1<<0)|(1<<2); // configuring the UART funtion
PINSEL0 &= ~((1<<1)|(1<<3));
U0LCR = (1<<0)|(1<<1)|(1<<7); // configuring line control register(LCR),DLATCH
U0DLM = 0; // Loding value DLM and DLL
U0DLL = 97;
U0LCR = (1<<0)|(1<<1); // disable the DLATCH register
}
char uart_rx (void)
{
while(!(U0LSR & (1<<0)));
return (U0RBR);
}
int uart_rx1(void)
{
while(!(U0LSR&(1<<0)));
return(U0RBR);
}
void uart_tx1(int c)
{
while(!(U0LSR & (1<<5)));
U0THR = c;
}
void uart_tx(char c)
{
while(!(U0LSR & (1<<5)));
U0THR = c;
}
void uart_tx_string(char *str)
{
while(*str)
{
uart_tx(*str);
str++;
}
}
int main()
{
char k ='a';
char r;
int i,count=0,result=1,h=1;
uart_int();
g:
// result=adc();
init_rtc();
if(result==1)
{
k+=rand()%10;
uart_tx(k);
{
while(!(U0LSR & (1<<5)));
U0THR = c;
}
void uart_tx_string(char *str)
{
while(*str)
{
uart_tx(*str);
str++;
}
}
int main()
{
char k ='a';
char r;
int i,count=0,result=1,h=1;
uart_int();
g:
// result=adc();
init_rtc();
if(result==1)
{
k+=rand()%10;
uart_tx(k);
uart_tx_string("enter otp");
while(((MIN==ALMIN))
{
c:
if(count!=3)
{
while(h)
{
for(i=0;i<1;i++)
{
r=uart_rx();
uart_tx(r);
}
h=0;
}
if(r==k)
{
uart_tx_string("opening door please wait");
delay(2000);
h=1;
}
}
else
{
count++;
goto c;
}
break;
}
goto g;
while(((MIN==ALMIN))
{
c:
if(count!=3)
{
while(h)
{
for(i=0;i<1;i++)
{
r=uart_rx();
uart_tx(r);
}
h=0;
}
if(r==k)
{
uart_tx_string("opening door please wait");
delay(2000);
h=1;
}
}
else
{
count++;
goto c;
}
break;
}
goto g;
}
Comments
Post a Comment