Skip to content

Instantly share code, notes, and snippets.

@vivekanandRdhakane
Last active April 6, 2020 20:04
Show Gist options
  • Save vivekanandRdhakane/acbf120b1c259444da9bfb6e40878f68 to your computer and use it in GitHub Desktop.
Save vivekanandRdhakane/acbf120b1c259444da9bfb6e40878f68 to your computer and use it in GitHub Desktop.
//Author: Vivekanand Dhakane
//Uploaded on: 4 April 2020
#include <Servo.h>
#define threshold 405
#define unpress_angle 70
#define press_angle 36
Servo myservo; // create servo object to control a servo
bool trig=true;
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
myservo.write(unpress_angle);
}
void loop() {
myservo.write(unpress_angle); // unpress the button
delay(1);
if(analogRead(A0)< threshold)
{
myservo.write(press_angle); // press the button
delay(100 ); // waits 100ms for the servo to reach the position
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment