Imagine | Develop | Create
#include <Servo.h> Servo shootingServo; #define motorpin A1 #define startpin 0 unsigned long lastHigh = 0; void setup() { shootingServo.attach(9); shootingServo.write(0); pinMode(motorpin, OUTPUT); pinMode(startpin, INPUT); pinMode(1, INPUT); digitalWrite(1,HIGH); } void loop() { if(digitalRead(startpin)==HIGH) { lastHigh = millis(); digitalWrite(motorpin,HIGH); shootingServo.write(120); } else { shootingServo.write(40); } if(lastHigh+1000 < millis()) { digitalWrite(motorpin,LOW); shootingServo.write(40); } }