A Magnetic Door Lock employing Arduino
             Technology




                 BY,
        SRAVANTHI RANI SINHA S
A Magnetic Door Lock employing Arduino
                   Technology


• 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.
1. Arduino Introduction

2. Variety and Shields and Sensors

3. Applications

4. Design and Development of Magnetic DOOR
   lock
Arduino is a board
   USB to Serial             Digital In/Out Pins




 USB Port
                                                   Atmega328p




Power Supply


                       Power Pins     Analog Input Pins
Hardware Features
Microcontroller                                       ATmega168/ATmega328
Operating Voltage                                                 5V
  Microcontroller             ATmega168
Input Voltage (recommended)
  Operating Voltage           5V                                       7-12V
Input Voltage (limits) 7-12V
  Input Voltage (recommended)
  Input Voltage (limits)      6-20V
                                                                       6-20V
DigitalI/O Pins
  Digital I/O Pins            14 (of which 6 provide PWM(of which 6 provide PWM output)
                                                      14 output)
  Analog Input Pins           6
Analog Input Pins
  DC Current per I/O Pin      40 mA                                       6
DC Current per Pin Pin 50 mA
  DC Current for 3.3V
                       I/O                                             40 mA
                              16 KB (ATmega168) or 32 KB (ATmega328) of which 2 KB used by
  Flash Memory
DC Current for 3.3V Pin bootloader                                     50 mA
  SRAM                        1 KB (ATmega168) or 2 KB (ATmega328)
  EEPROM                      512 bytes (ATmega168) or 116 (ATmega328)
                                                         KB KB (ATmega168) or 32 KB
Flash Speed
  Clock Memory                16 MHz                  (ATmega328) of which 2 KB used by
                                                            bootloader
                                                   1 KB (ATmega168) or 2 KB
SRAM
                                                          (ATmega328)
                                                 512 bytes (ATmega168) or 1 KB
EEPROM
                                                          (ATmega328)
Clock Speed                                                  16 MHz
BLOCK DIAGRAM OF ATMEGA MICROCONTROLLER
ATMEGA168 MICROCONTROLLER
Its 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



Ethernet      WiFi      RFID




                         GPS

Bluetooth      GPRS
Sensors



IR Thermometer            Smoke Detector   Pressure




Polar Heart Rate Sensor        RTC         pH Sensor
3. Applications
Heart Rate Monitor Interface
Arduino Electric Blinds
http://bitly.com/zfZT3H




                                      Gear Motor
Barcode scanner
Lego and Arduino
http://bitly.com/wLBvY0




     NXShield
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>                                                void loop()
#include <EEPROM.h>                                                {
char* secretCode = "1234";                                         char key = keypad.getKey();
int position = 0;                                                  if (key == '*' && ! Locked)
boolean locked = true;                                              {
const byte rows = 4;                                               // unlocked and * pressed so change code
const byte cols = 3;                                               position = 0;
char keys[rows][cols] =                                            getNewCode();
      {{'1','2','3'},{'4','5','6'},{'7','8','9'},{'*','0','#'}};   updateOutputs();
byte rowPins[rows] = {2, 7, 6, 4};                                  }
byte colPins[cols] = {3, 1, 5};                                    if (key == '#‘){
Keypad keypad = Keypad(makeKeymap(keys), rowPins,                  locked = true;
      colPins, rows, cols);                                        position = 0;
int redPin = 9;                                                    updateOutputs(); }
int greenPin = 8;                                                  if (key == secretCode[position]){position ++;}
int solenoidPin = 10;                                              if (position == 4)
void setup() {                                                     {
pinMode(redPin, OUTPUT);                                           locked = false;
pinMode(greenPin, OUTPUT);                                         updateOutputs();
loadCode();                                                        }
flash();                                                           delay(100);
updateOutputs(); }                                                 }
void updateOutputs()                       void loadCode()
{                                          {
if (locked){                               if (EEPROM.read(0) == 1){
digitalWrite(redPin, HIGH);                secretCode[0] = EEPROM.read(1);
digitalWrite(greenPin, LOW);               secretCode[1] = EEPROM.read(2);
digitalWrite(solenoidPin, HIGH);}          secretCode[2] = EEPROM.read(3);
else{                                      secretCode[3] = EEPROM.read(4);}
digitalWrite(redPin, LOW);                 }
digitalWrite(greenPin, HIGH);               void saveCode()
digitalWrite(solenoidPin, LOW);}           {
}                                          EEPROM.write(1, secretCode[0]);
                                           EEPROM.write(2, secretCode[1]);
 void getNewCode(){                        EEPROM.write(3, secretCode[2]);
flash();                                   EEPROM.write(4, secretCode[3]);
for (int i = 0; i < 4; i++ )               EEPROM.write(0, 1);
{                                          }
char key;                                  void flash()
key = keypad.getKey();                     {
while (key == 0){key = keypad.getKey();}   digitalWrite(redPin, HIGH);
flash();                                   digitalWrite(greenPin, HIGH);
secretCode[i] = key;                       delay(500);
}                                          digitalWrite(redPin, LOW);
saveCode();flash();flash();                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)

Magnetic door lock using arduino

  • 1.
    A Magnetic DoorLock employing Arduino Technology BY, SRAVANTHI RANI SINHA S
  • 2.
    A Magnetic DoorLock employing Arduino Technology • 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.
  • 3.
    1. Arduino Introduction 2.Variety and Shields and Sensors 3. Applications 4. Design and Development of Magnetic DOOR lock
  • 4.
    Arduino is aboard USB to Serial Digital In/Out Pins USB Port Atmega328p Power Supply Power Pins Analog Input Pins
  • 5.
    Hardware Features Microcontroller ATmega168/ATmega328 Operating Voltage 5V Microcontroller ATmega168 Input Voltage (recommended) Operating Voltage 5V 7-12V Input Voltage (limits) 7-12V Input Voltage (recommended) Input Voltage (limits) 6-20V 6-20V DigitalI/O Pins Digital I/O Pins 14 (of which 6 provide PWM(of which 6 provide PWM output) 14 output) Analog Input Pins 6 Analog Input Pins DC Current per I/O Pin 40 mA 6 DC Current per Pin Pin 50 mA DC Current for 3.3V I/O 40 mA 16 KB (ATmega168) or 32 KB (ATmega328) of which 2 KB used by Flash Memory DC Current for 3.3V Pin bootloader 50 mA SRAM 1 KB (ATmega168) or 2 KB (ATmega328) EEPROM 512 bytes (ATmega168) or 116 (ATmega328) KB KB (ATmega168) or 32 KB Flash Speed Clock Memory 16 MHz (ATmega328) of which 2 KB used by bootloader 1 KB (ATmega168) or 2 KB SRAM (ATmega328) 512 bytes (ATmega168) or 1 KB EEPROM (ATmega328) Clock Speed 16 MHz
  • 6.
    BLOCK DIAGRAM OFATMEGA MICROCONTROLLER
  • 7.
    ATMEGA168 MICROCONTROLLER Its featuresincludes: • 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 .
  • 11.
    2. Arduino Variety,Shields and Sensors
  • 12.
  • 13.
    Arduino Shield Add-on module to extend arduino’s capabilities. Also called Daughterboard or Cape
  • 14.
  • 15.
    Communication Shields Ethernet WiFi RFID GPS Bluetooth GPRS
  • 16.
    Sensors IR Thermometer Smoke Detector Pressure Polar Heart Rate Sensor RTC pH Sensor
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
    Design and Developmentof 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
  • 23.
  • 24.
  • 25.
    The software forthis project #include <Keypad.h> void loop() #include <EEPROM.h> { char* secretCode = "1234"; char key = keypad.getKey(); int position = 0; if (key == '*' && ! Locked) boolean locked = true; { const byte rows = 4; // unlocked and * pressed so change code const byte cols = 3; position = 0; char keys[rows][cols] = getNewCode(); {{'1','2','3'},{'4','5','6'},{'7','8','9'},{'*','0','#'}}; updateOutputs(); byte rowPins[rows] = {2, 7, 6, 4}; } byte colPins[cols] = {3, 1, 5}; if (key == '#‘){ Keypad keypad = Keypad(makeKeymap(keys), rowPins, locked = true; colPins, rows, cols); position = 0; int redPin = 9; updateOutputs(); } int greenPin = 8; if (key == secretCode[position]){position ++;} int solenoidPin = 10; if (position == 4) void setup() { { pinMode(redPin, OUTPUT); locked = false; pinMode(greenPin, OUTPUT); updateOutputs(); loadCode(); } flash(); delay(100); updateOutputs(); } }
  • 26.
    void updateOutputs() void loadCode() { { if (locked){ if (EEPROM.read(0) == 1){ digitalWrite(redPin, HIGH); secretCode[0] = EEPROM.read(1); digitalWrite(greenPin, LOW); secretCode[1] = EEPROM.read(2); digitalWrite(solenoidPin, HIGH);} secretCode[2] = EEPROM.read(3); else{ secretCode[3] = EEPROM.read(4);} digitalWrite(redPin, LOW); } digitalWrite(greenPin, HIGH); void saveCode() digitalWrite(solenoidPin, LOW);} { } EEPROM.write(1, secretCode[0]); EEPROM.write(2, secretCode[1]); void getNewCode(){ EEPROM.write(3, secretCode[2]); flash(); EEPROM.write(4, secretCode[3]); for (int i = 0; i < 4; i++ ) EEPROM.write(0, 1); { } char key; void flash() key = keypad.getKey(); { while (key == 0){key = keypad.getKey();} digitalWrite(redPin, HIGH); flash(); digitalWrite(greenPin, HIGH); secretCode[i] = key; delay(500); } digitalWrite(redPin, LOW); saveCode();flash();flash(); digitalWrite(greenPin, LOW); } }
  • 27.
  • 28.
    Conclusion and futurescope • 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.
  • 29.
    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)

Editor's Notes

  • #3 The main aim of the work undertaken in this paper is 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 which when powered, will strongly attract the metal slug in its center, pulling it into place, when the power is removed, it is free to move.
  • #8 ATmega168 is widely used because it supports wide range of system development tools such as C Compliers, Macro assemblers, Program Debugger/Simulators, In-circuit Emulators and Evaluation Kits . Its features includes: 23 general purpose I/O lines, 32 general purpose working registers, three 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 .
  • #9 VCCDigital supply voltage.GNDGround voltage for the microcontroller chip.PORT B (PB7:0)  Port B is an 8-bit bi-directional I/O Port with internal pull-up resistors. As Inputs, Port B pins that are externally pulled low will source current if the pull-up resistors are activated.Depending on the clock selection fuse settings, PB6 can be used as input to the inverting oscillator amplifier and input to the internal clock operating circuit Depending on the clock selection fuse settings, PB7 can be used as output from inverting oscillating amplifier .PORT C (PC5:0) Port C is a 7-bit bi-directional I/O port with internal pull-up resistors. As inputs,Port C pins that are externally pulled low will source current if the pull-up resistors are activated .PC6/RESET :If the RSTDISBL register is programmed, PC6 is used as I/O pin. Behavior of PC6 is different from other Port C pins.If RSTDISBL is not programmed, PC6 can be used as a Reset input. A low level on this pin for longer than the minimum pulse length will generate a reset even without the clock signal. Shorter pulses are not guaranteed to generate a Reset .PORT D (PD7:0)Port D is an 8-bit bi-directional I/O port with internal pull-up resistors. As inputs,Port C pins that are externally pulled low will source current if the pull-up resistors are activated. The Port D pins become tri-stated if the reset condition become active, even if the clock is running .AVCC AVCC is the supply pin for the A/D Convertor, PC[5:0]. It should be externally connected to VCC, even if the ADC is not used. If the ADC is used it should be connectedto VCC through low pass filter AREFAREF is an analog reference pin for the A/D convertor.XTAL1 It is an input to the inverting oscillator amplifier and the internal clock circuit.XTAL2It is an output pin from the inverting oscillator amplifier. 
  • #11 The Arduino Duemilanove (&quot;2009&quot;) is a microcontroller board based on the  ATmega168  or ATmega328. It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started.