文件大小:1.82M
// ThirdHand test script // by Tim Giles//servo is on Pin8 //button is on Pin3 and has the pullup enabled #include Servo ServoA; int Angle = 10; int AngleClosed = 10; int AngleOpen = 120; void setup() { ServoA.attach(8); pinMode(3,INPUT_PULLUP);} void loop() { //update the servo position ServoA.write(Angle); delay(1); //check if the button is pushed if (digitalRead(3) == 0) { //debounce while (digitalRead(3) == 0){ delay(1); } //set the servo to it's open position Angle = AngleOpen; ServoA.write(Angle); //hold the servo in this position to give the user time //to grab the screwdriver delay(2000); //set the servo to it's closed position Angle = AngleClosed; ServoA.write(Angle); }}