Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Password-Protected Servo Lock with LED Indicators

View and Edit Project In Cirkit DesignerImage of Arduino UNO Password-Protected Servo Lock with LED Indicators

Circuit Documentation

Summary

This circuit is designed to control a servo motor and two LEDs using an Arduino UNO microcontroller. It also includes a 4x4 membrane matrix keypad for user input. The circuit is powered by a 9V battery and USB power. The red and green LEDs indicate the lock and unlock status, respectively, and the servo motor moves based on the keypad input.

Component List

  1. Arduino UNO

    • Description: Microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. LED: Two Pin (red)

    • Description: Red LED with two pins.
    • Pins: cathode, anode
  3. LED: Two Pin (green)

    • Description: Green LED with two pins.
    • Pins: cathode, anode
  4. Servo

    • Description: Servo motor with three pins.
    • Pins: gnd, vcc, pulse
  5. 4X4 Membrane Matrix Keypad

    • Description: Keypad with 4 rows and 4 columns.
    • Pins: R1, R2, R3, R4, C1, C2, C3, C4
  6. Resistor (200 Ohms)

    • Description: Resistor with 200 Ohms resistance.
    • Pins: pin1, pin2
  7. 9V battery

    • Description: 9V battery for power supply.
    • Pins: +, -
  8. USB power

    • Description: USB power supply.
    • Pins: +, -

Wiring Details

Arduino UNO

LED: Two Pin (red)

LED: Two Pin (green)

Servo

4X4 Membrane Matrix Keypad

Resistor (200 Ohms)

9V battery

USB power

Documented Code

Arduino UNO Code

#include <Servo.h>
#include <Keypad.h>

Servo ServoMotor;
char*  password = "427";  // change the password here, just pick any 3 numbers
int  position = 0;
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS]  = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};

byte  rowPins[ROWS] = { 8, 7, 6, 9 };
byte colPins[COLS] = { 5, 4, 3, 2 };
Keypad  keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
int RedpinLock  = 12;
int GreenpinUnlock = 13;

void setup()
{
  pinMode(RedpinLock,  OUTPUT);
  pinMode(GreenpinUnlock, OUTPUT);
  ServoMotor.attach(11);
  LockedPosition(true);
}

void  loop()
{
  char key = keypad.getKey();
  if (key == '*' || key == '#')
  {
    position  = 0;
    LockedPosition(true);
  }
  if (key == password[position])
  {
    position  ++;
  }
  if (position == 3)
  {
    LockedPosition(false);
  }
  delay(100);
}

void  LockedPosition(int locked)
{
  if (locked)
  {
    digitalWrite(RedpinLock,  HIGH);
    digitalWrite(GreenpinUnlock, LOW);
    ServoMotor.write(11);
  }
  else
  {
    digitalWrite(RedpinLock,  LOW);
    digitalWrite(GreenpinUnlock, HIGH);
    ServoMotor.write(90);
  }
}

4X4 Membrane Matrix Keypad Code

void setup() {
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly:
}

This documentation provides a comprehensive overview of the circuit, including the components used, their wiring details, and the code running on the microcontrollers.