Aim:
Build a system that opens a tap automatically when hands are detected and closes it when hands are removed.
Requirements:
- Arduino Uno or Raspberry Pi Pico
- IR proximity sensor
- Servo motor (SG90 or similar)
- Breadboard and jumper wires
- USB cable and Arduino IDE / Thonny
Working principle:
- The IR sensor emits infrared light and detects if it reflects back from a nearby object (like your hand).
- Arduino receives this signal and sends a command to the servo.
- The servo rotates to open the tap when hands are present and rotates back to close it when hands are removed.
Circuit Connections
IR Sensor
- VCC → 5V
- GND → GND
- OUT → Pin 2 (Arduino)
Servo Motor
- VCC (Red) → 5V
- GND (Brown/Black) → GND
- Signal (Orange/Yellow) → Pin 9 (Arduino)
Step-by-Step Instructions
Step 1: Wiring
- Connect IR sensor output pin to Arduino pin 2.
- Connect servo motor signal wire to Arduino pin 9.
- Ensure all components share a common ground.
Step 2: Arduino Code (Basic Version)
#include <Servo.h>
Servo tapServo;
int sensorPin = 2;
int sensorValue = 0;
void setup() {
tapServo.attach(9);
pinMode(sensorPin, INPUT);
tapServo.write(0); // Tap closed
}
void loop() {
sensorValue = digitalRead(sensorPin);
if (sensorValue == LOW) { // Object detected
tapServo.write(90); // Open tap
} else {
tapServo.write(0); // Close tap
}
}
Step 3: Testing
- Place your hand near the IR sensor.
- The servo should rotate to open the tap.
- Remove your hand and the servo should rotate back to close it.