Magnetic door lock using arduino

Preview:

Citation preview

A Magnetic Door Lock employing Arduino Technology

 

BY,SRAVANTHI RANI SINHA S

• To sense the correctness of a secret code using the Arduino technology.

• When the correct code is entered through keypad, it lights a green LED in addition to operating a small solenoid.

A Magnetic Door Lock employing Arduino Technology

 

1. Arduino Introduction

2. Variety and Shields and Sensors

3. Applications

4. Design and Development of Magnetic DOOR lock

Arduino is a board

USB Port

Power Supply

Digital In/Out Pins

Analog Input Pins

Power Pins

Atmega328p

USB to Serial

Hardware Features

Microcontroller ATmega168Operating Voltage 5VInput Voltage (recommended) 7-12VInput Voltage (limits) 6-20VDigital I/O Pins 14 (of which 6 provide PWM output)Analog Input Pins 6DC Current per I/O Pin 40 mADC Current for 3.3V Pin 50 mA

Flash Memory 16 KB (ATmega168) or 32 KB (ATmega328) of which 2 KB used by bootloader

SRAM 1 KB (ATmega168) or 2 KB (ATmega328)EEPROM 512 bytes (ATmega168) or 1 KB (ATmega328)Clock Speed 16 MHz

Microcontroller ATmega168/ATmega328

Operating Voltage 5V

Input Voltage (recommended) 7-12V

Input Voltage (limits) 6-20V

Digital I/O Pins 14 (of which 6 provide PWM output)

Analog Input Pins 6

DC Current per I/O Pin 40 mA

DC Current for 3.3V Pin 50 mA

Flash Memory16 KB (ATmega168) or 32 KB

(ATmega328) of which 2 KB used by bootloader

SRAM1 KB (ATmega168) or 2 KB

(ATmega328)

EEPROM512 bytes (ATmega168) or 1 KB

(ATmega328)Clock Speed 16 MHz

BLOCK DIAGRAM OF ATMEGA MICROCONTROLLER

ATMEGA168 MICROCONTROLLERIts features includes:

• 23 general purpose I/O lines• 32 general purpose working registers• 3 flexible timer/counters with compare/capture/PWM mode, a SPI serial

port• 16K bytes of in-system programmable Flash with Read-while-Write

capabilities.• 512 bytes of EEPROM and 1K bytes SRAM.• In Idle mode CPU stops working while allowing the SRAM,

timers/counters, USART, SPI port and interrupt system to continue functioning.

• It also has 6 channel 10-bit ADC, a programmable watchdog timer with internal oscillator .

2. Arduino Variety, Shields and Sensors

Arduino Variety

Arduino Shield

Add-on module to extend arduino’s capabilities. Also called Daughterboard

or Cape

Shields

Communication Shields

RFIDEthernet WiFi

Bluetooth GPRS

GPS

Sensors

IR Thermometer Smoke Detector Pressure

Polar Heart Rate Sensor RTC pH Sensor

3. Applications

Heart Rate Monitor Interface

Arduino Electric Blindshttp://bitly.com/zfZT3H

Gear Motor

Barcode scanner

Lego and Arduino

NXShield

http://bitly.com/wLBvY0

Design and Development of Magnetic Door lock

COMPONENTS AND EQUIPMENT

• Arduino Diecimila or Duemilanove board or clone

• D1 Red 5-mm LED• D2 Green 5-mm LED• R1-3 270 resistor• K1 4 x 3 keypad• 0.1-inch header strip• T1 BC548• 5V solenoid (< 100 mA)• D3 1N4004

The schematic diagram

The Bread Board Layout

The software for this project#include <Keypad.h>#include <EEPROM.h> char* secretCode = "1234";int position = 0;boolean locked = true;const byte rows = 4;const byte cols = 3;char keys[rows][cols] = {{'1','2','3'},{'4','5','6'},{'7','8','9'},

{'*','0','#'}};byte rowPins[rows] = {2, 7, 6, 4};byte colPins[cols] = {3, 1, 5};Keypad keypad = Keypad(makeKeymap(keys), rowPins,

colPins, rows, cols);int redPin = 9;int greenPin = 8;int solenoidPin = 10; void setup() {pinMode(redPin, OUTPUT);pinMode(greenPin, OUTPUT);loadCode();flash();updateOutputs(); }

void loop(){char key = keypad.getKey();if (key == '*' && ! Locked) {// unlocked and * pressed so change codeposition = 0;getNewCode();updateOutputs(); }if (key == '#‘){locked = true;position = 0;updateOutputs(); }if (key == secretCode[position]){position ++;}if (position == 4){locked = false;updateOutputs();}delay(100);}

void updateOutputs(){if (locked){digitalWrite(redPin, HIGH);digitalWrite(greenPin, LOW);digitalWrite(solenoidPin, HIGH);}else{digitalWrite(redPin, LOW);digitalWrite(greenPin, HIGH);digitalWrite(solenoidPin, LOW);}}

void getNewCode(){flash();for (int i = 0; i < 4; i++ ){char key;key = keypad.getKey();while (key == 0){key = keypad.getKey();}flash();secretCode[i] = key;}saveCode();flash();flash();}

void loadCode(){if (EEPROM.read(0) == 1){secretCode[0] = EEPROM.read(1);secretCode[1] = EEPROM.read(2);secretCode[2] = EEPROM.read(3);secretCode[3] = EEPROM.read(4);}} void saveCode(){EEPROM.write(1, secretCode[0]);EEPROM.write(2, secretCode[1]);EEPROM.write(3, secretCode[2]);EEPROM.write(4, secretCode[3]);EEPROM.write(0, 1);} void flash(){digitalWrite(redPin, HIGH);digitalWrite(greenPin, HIGH);delay(500);digitalWrite(redPin, LOW);digitalWrite(greenPin, LOW);}

Putting It All Together

Conclusion and future scope

• A Magnetic Door Lock employing Arduino technology is presented. we have implemented a fail safe maglock ,fail secure maglock also can be implemented.

• Instead of keypad Reader using the variety of sensors and shields various combinations of Magnetic Door Lock can be produced and installed according to the requirements of any Industry.

References• http://arduino.cc/• ITP Physical Computing• http://www.ladyada.net• http://www.sparkfun.com• http://www.openlabtaipei.org/ (Openlab Taipei)• http://seeedstudio.com• http://coopermaa2nd.blogspot.com

Thank you,Sravanthi Rani Sinha s

(09BD1A04A0)

Recommended