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

Arduino-Based Smart Security System with Ultrasonic Sensor, Keypad, and RGB LED

View and Edit Project In Cirkit DesignerImage of Arduino-Based Smart Security System with Ultrasonic Sensor, Keypad, and RGB LED

Circuit Documentation

Summary

This circuit consists of various components including an Arduino UNO, sensors, LEDs, a keypad, an LCD, and a buzzer. The circuit is designed to perform multiple functions such as detecting obstacles using an ultrasonic sensor, reading sound levels, displaying information on an LCD, and evaluating password strength entered via a keypad. The RGB LED and other LEDs provide visual feedback based on sensor inputs and password strength.

Component List

  1. 4X4 Membrane Matrix Keypad

    • Pins: R1, R2, R3, R4, C1, C2, C3, C4
    • Description: A keypad used for inputting passwords.
    • Purpose: To allow user input for password evaluation.
  2. 8x8 Matrix

    • Pins: vcc, DIN, clk, CS, Gnd, gnd, CLK
    • Description: An 8x8 LED matrix.
    • Purpose: To display patterns or information visually.
  3. Arduino UNO

    • 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
    • Description: A microcontroller board.
    • Purpose: To control the circuit and execute the embedded code.
  4. Ultrasonic Sensor

    • Pins: +VCC, Trigger, Echo, GND
    • Description: A sensor to measure distance.
    • Purpose: To detect obstacles and measure distance.
  5. LED: Two Pin (red)

    • Pins: cathode, anode
    • Description: A red LED.
    • Purpose: To provide visual feedback.
  6. LED: Two Pin (green)

    • Pins: cathode, anode
    • Description: A green LED.
    • Purpose: To provide visual feedback.
  7. LED: Two Pin (yellow)

    • Pins: cathode, anode
    • Description: A yellow LED.
    • Purpose: To provide visual feedback.
  8. Resistor

    • Pins: pin1, pin2
    • Description: A resistor with 200 Ohms resistance.
    • Purpose: To limit current through LEDs.
  9. 16x2 I2C LCD

    • Pins: GND, VCC, SDA, SCL
    • Description: A 16x2 character LCD with I2C interface.
    • Purpose: To display information.
  10. Buzzer

    • Pins: PIN, GND
    • Description: A buzzer.
    • Purpose: To provide audible feedback.
  11. RGB LED (Wokwi compatible)

    • Pins: R, COM, G, B
    • Description: An RGB LED.
    • Purpose: To provide multi-color visual feedback.
  12. Sound Sensor

    • Pins: Analog, GND, VCC, Digital
    • Description: A sensor to detect sound levels.
    • Purpose: To detect sound and provide input to the microcontroller.

Wiring Details

4X4 Membrane Matrix Keypad

8x8 Matrix

Arduino UNO

Ultrasonic Sensor

LED: Two Pin (red)

LED: Two Pin (green)

LED: Two Pin (yellow)

Resistor

16x2 I2C LCD

Buzzer

RGB LED (Wokwi compatible)

Sound Sensor

Documented Code

Arduino UNO (Instance 1)

// Pin Definitions
const int trigPin = 9;
const int echoPin = 8;
const int redPin = 3;
const int greenPin = 5;
const int bluePin = 6;
const int micPin = 11;

// Thresholds
const int distanceThreshold = 20; // in cm
const int soundThreshold = 500;  // Adjust based on sound module output
const int debounceDelay = 200;   // Debounce delay for sound input in ms

// Variables
long duration;
int distance;
bool stopCommand = false;       // Tracks if the "stop" command has been detected
static unsigned long lastSoundTime = 0;

void setup() {
  // Ultrasonic Sensor
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);

  // RGB LED
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);

  // Microphone
  pinMode(micPin, INPUT);

  // Serial Monitor
  Serial.begin(9600);
}

void loop() {
  // Measure distance using Ultrasonic Sensor
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = duration * 0.034 / 2; // Convert to cm

  // Read sound level
  int soundLevel = analogRead(micPin);
  Serial.print("Sound Level: ");
  Serial.print(soundLevel);
  Serial.print(" | Distance: ");
  Serial.print(distance);
  Serial.print(" cm | Stop Command: ");
  Serial.println(stopCommand ? "ON" : "OFF");

  // Check for the "stop" command
  if (soundLevel > soundThreshold