Skip to content

Latest commit

 

History

History
67 lines (52 loc) · 2.49 KB

README.md

File metadata and controls

67 lines (52 loc) · 2.49 KB

ir-control-stepper

Cap Dispenser Using IR Sensor and Stepper Motor

Overview

This project is a simple and efficient cap dispenser system powered by an Arduino Uno, a single IR sensor, and a stepper motor. The system detects a hand near the dispenser to start the motor and stops the motor once the operator removes their hand after the cap has been dispensed.

Features

  • Hand Detection: Utilizes a single IR sensor to detect the presence of a hand.
  • Automatic Dispensing: Starts the motor when a hand is detected and stops the motor once the hand is removed.
  • Simplified Design: Uses only one IR sensor for streamlined operation.

Hardware Requirements

  • Arduino Uno
  • Stepper motor (compatible with the AccelStepper library)
  • Stepper motor driver (e.g., A4988 or similar)
  • Single IR sensor
  • Power supply for the stepper motor
  • Wires and connectors

Software Requirements

  • Arduino IDE (latest version recommended)
  • AccelStepper library (included in the Arduino IDE library manager)

Circuit Diagram

Ensure the following connections:

  1. IR Sensor:

    • VCC → 5V
    • GND → GND
    • OUT → Digital Pin 9
  2. Stepper Motor Driver:

    • DIR → Digital Pin 2
    • STEP → Digital Pin 3
    • VCC, GND → Power supply for the motor
  3. Arduino Uno:

    • Connect as per the above pin configuration.

Code

The source code for this project is located in the cap_dispenser.ino file. It is written in C++ using the Arduino IDE.

Workflow:

  1. When the IR sensor detects a hand, the motor starts dispensing.
  2. After the cap is dispensed, the operator removes their hand, and the motor stops.

Key Functions:

  • detectHand(): Detects the presence of a hand using the IR sensor.
  • startMotor(): Starts the stepper motor to dispense a cap.
  • stopMotor(): Stops the stepper motor when the hand is removed.

How to Run

  1. Connect the hardware as per the circuit diagram.
  2. Install the AccelStepper library using the Arduino Library Manager.
  3. Upload the provided code to the Arduino Uno using the Arduino IDE.
  4. Power the system and observe the dispensing process.

Usage

  • Place a hand near the IR sensor to start the motor and dispense a cap.
  • Remove your hand after the cap is dispensed to stop the motor.
  • Repeat the process for each cap.

License

This project is open-source and available under the MIT License.

Acknowledgments

Special thanks to the developers of the AccelStepper library for providing easy-to-use motor control functionality.