Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino UNO Controlled Motorized Drawer with Clap Activation and LED Indicator

Image of Arduino UNO Controlled Motorized Drawer with Clap Activation and LED Indicator

Circuit Documentation

Summary

This circuit is designed to control a 12V geared motor and a blue LED using an Arduino UNO microcontroller based on input from a sound sensor and a limit switch. The motor's direction is controlled by an L298N DC motor driver, and the LED is switched on and off using a 1-channel 5V relay module. The system also includes a 12V power supply to power the motor and the LED. An I2C LCD screen is used to display the system status.

Component List

Arduino UNO

  • Microcontroller board based on the ATmega328P
  • Provides I/O pins and power to various components in the circuit

12V Geared Motor

  • A motor that converts electrical energy into mechanical energy
  • Operated by the L298N motor driver

12V Power Supply

  • Provides the necessary power to the motor and the LED

12V Blue LED

  • An indicator light that illuminates when the relay is activated

L298N DC Motor Driver

  • An H-bridge motor driver that allows for the control of the motor's direction

Sound Sensor

  • Detects sound and sends a digital signal to the Arduino

1 Channel 5V Relay Module

  • Controls high power devices, such as the LED, using a low power signal from the Arduino

Limit Switch

  • A switch that will be activated when a moving part reaches a certain point

I2C LCD 16x2 Screen

  • Displays text information regarding the system status

Wiring Details

Arduino UNO

  • 5V to Relay Module VCC+, Sound Sensor VCC
  • GND to Limit Switch NO, Relay Module VCC- (GND), COM, I2C LCD Screen GND, Sound Sensor GND, L298N Motor Driver GND
  • Vin to 12V Power Supply +, 12V Blue LED VCC, L298N Motor Driver 12V
  • A4 to I2C LCD Screen SDA
  • A5 to I2C LCD Screen SCL
  • D10 to L298N Motor Driver ENA
  • D6 to Limit Switch C
  • D5 to L298N Motor Driver IN2
  • D4 to L298N Motor Driver IN1
  • D3 to Relay Module IN
  • D2 to Sound Sensor Digital

12V Geared Motor

  • Terminal 1 to L298N Motor Driver OUT1
  • Terminal 2 to L298N Motor Driver OUT2

12V Power Supply

  • - to Arduino UNO GND

12V Blue LED

  • GND to Relay Module N.O.

L298N DC Motor Driver

  • GND to Arduino UNO GND
  • 12V to Arduino UNO Vin
  • ENA to Arduino UNO D10
  • IN1 to Arduino UNO D4
  • IN2 to Arduino UNO D5
  • OUT1 to 12V Geared Motor Terminal 1
  • OUT2 to 12V Geared Motor Terminal 2

Sound Sensor

  • VCC to Arduino UNO 5V
  • GND to Arduino UNO GND
  • Digital to Arduino UNO D2

1 Channel 5V Relay Module

  • VCC+ to Arduino UNO 5V
  • VCC- (GND) to Arduino UNO GND
  • IN to Arduino UNO D3
  • COM to Arduino UNO GND
  • N.O. to 12V Blue LED GND

Limit Switch

  • C to Arduino UNO D6
  • NO to Arduino UNO GND

I2C LCD 16x2 Screen

  • SDA to Arduino UNO A4
  • SCL to Arduino UNO A5
  • GND to Arduino UNO GND

Documented Code

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Pin Definitions
const int soundSensorPin = 2;       // Digital pin for sound sensor
const int relayPin = 3;             // Digital pin for relay (LED)
const int motorForwardPin = 4;      // Motor driver forward control pin
const int motorBackwardPin = 5;     // Motor driver backward control pin
const int limitSwitchPin = 6;       // Limit switch pin

// LCD Setup
LiquidCrystal_I2C lcd(0x27, 16, 2); // Adjust address as necessary

// State Variables
bool drawerOpen = false;

void setup() {
    // Initialize pins
    pinMode(soundSensorPin, INPUT);
    pinMode(relayPin, OUTPUT);
    pinMode(motorForwardPin, OUTPUT);
    pinMode(motorBackwardPin, OUTPUT);
    pinMode(limitSwitchPin, INPUT_PULLUP); // Use internal pull-up resistor

    // Initialize LCD
    lcd.begin();
    lcd.backlight();
    lcd.print("Ready to Clap");
}

void loop() {
    // Check for clap
    if (digitalRead(soundSensorPin) == HIGH) {
        delay(200); // Debounce delay for sound sensor

        if (!drawerOpen) {
            openDrawer();
        } else {
            closeDrawer();
        }

        // Wait until clap is no longer detected
        while (digitalRead(soundSensorPin) == HIGH) {
            delay(50);
        }
    }
}

void openDrawer() {
    digitalWrite(relayPin, HIGH); // Turn on LED
    lcd.clear();
    lcd.print("Opening Drawer");
    digitalWrite(motorForwardPin, HIGH); // Move motor forward

    // Run motor until limit switch is pressed
    while (digitalRead(limitSwitchPin) == HIGH) {
        delay(50); // Debounce limit switch
    }

    digitalWrite(motorForwardPin, LOW); // Stop motor
    drawerOpen = true;
    lcd.clear();
    lcd.print("Drawer Open");
    delay(1000); // Pause to display message
    lcd.clear();
    lcd.print("Ready to Clap");
}

void closeDrawer() {
    digitalWrite(relayPin, LOW); // Turn off LED
    lcd.clear();
    lcd.print("Closing Drawer");
    digitalWrite(motorBackwardPin, HIGH); // Move motor backward

    // Run motor until limit switch is released
    while (digitalRead(limitSwitchPin) == LOW) {
        delay(50); // Debounce limit switch
    }

    digitalWrite(motorBackwardPin, LOW); // Stop motor
    drawerOpen = false;
    lcd.clear();
    lcd.print("Drawer Closed");
    delay(1000); // Pause to display message
    lcd.clear();
    lcd.print("Ready to Clap");
}

This code is designed to run on the Arduino UNO and controls the motor, LED, and LCD based on input from the sound sensor and limit switch. When a clap is detected by the sound sensor, the system will either open or close a drawer, indicated by the motor's movement and the LED's state. The LCD provides feedback on the system's status.