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

Arduino UNO Controlled Motorized Drawer with Clap Activation and LED Indicator

View and Edit Project In Cirkit DesignerImage 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

12V Geared Motor

12V Power Supply

12V Blue LED

L298N DC Motor Driver

Sound Sensor

1 Channel 5V Relay Module

Limit Switch

I2C LCD 16x2 Screen

Wiring Details

Arduino UNO

12V Geared Motor

12V Power Supply

12V Blue LED

L298N DC Motor Driver

Sound Sensor

1 Channel 5V Relay Module

Limit Switch

I2C LCD 16x2 Screen

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.