Last active
April 6, 2020 20:04
-
-
Save vivekanandRdhakane/acbf120b1c259444da9bfb6e40878f68 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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