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.
- 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.
- 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
- Arduino IDE (latest version recommended)
- AccelStepper library (included in the Arduino IDE library manager)
Ensure the following connections:
-
IR Sensor:
- VCC → 5V
- GND → GND
- OUT → Digital Pin 9
-
Stepper Motor Driver:
- DIR → Digital Pin 2
- STEP → Digital Pin 3
- VCC, GND → Power supply for the motor
-
Arduino Uno:
- Connect as per the above pin configuration.
The source code for this project is located in the cap_dispenser.ino
file. It is written in C++ using the Arduino IDE.
- When the IR sensor detects a hand, the motor starts dispensing.
- After the cap is dispensed, the operator removes their hand, and the motor stops.
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.
- Connect the hardware as per the circuit diagram.
- Install the AccelStepper library using the Arduino Library Manager.
- Upload the provided code to the Arduino Uno using the Arduino IDE.
- Power the system and observe the dispensing process.
- 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.
This project is open-source and available under the MIT License.
Special thanks to the developers of the AccelStepper library for providing easy-to-use motor control functionality.