Download the CAD files
Circuit Connection
Signal Pin of servo | Pin 6 on Arduino Nano |
Positive pin of servo | +5v on Arduino Nano |
Negative pin of servo | GND on Arduino Nano |
Positive pin of infrared sensor | +5v on Arduino Nano |
Negative pin of infrared sensor | GND on Arduino Nano |
Signal Pin of infrared sensor | Pin 7 on Arduino Nano |
Checkout the You-tube video to understand the project from the below link
Check out the code for the above project below
// Code by Tasty Tech Harbour
// Blog - www.tastytechharbour.com
// Personal website - www.srujancmutt.com
// Contact - contact@srujancmutt.com
// Youtube Channel - https://www.youtube.com/c/TastyTechHarbour/
#include <Servo.h>
Servo tap_servo;
int sensor_pin = 7;
int tap_servo_pin =6;
int val;
void setup(){
pinMode(sensor_pin,INPUT);
tap_servo.attach(tap_servo_pin);
}
void loop(){
val = digitalRead(sensor_pin);
if (val==0)
{
tap_servo.attach(tap_servo_pin);
tap_servo.write(50);
delay(650);
tap_servo.write(180);
delay(400);
}
if (val==1)
{
tap_servo.detach();
}
}