Hi everybody, could anyone help me on this? After having spent much time online, I’m about to give up.
here is my code.Really basic. I think it’s easy to understand without explanations:
#include <Servo.h>
Servo myservoR;
Servo myservoL;
int ledPinV = 13;
int ledPinR = 12;
int inputPin = 2;
void setup() {
myservoR.attach(5);
myservoL.attach(6);
pinMode(ledPinV, OUTPUT);
pinMode(ledPinR, OUTPUT);
pinMode(inputPin, INPUT); }
void loop() { int val = digitalRead(inputPin);
if (val == HIGH)
{ digitalWrite(ledPinV,LOW);
myservoR.writeMicroseconds(900); //trigger le right servo
myservoL.writeMicroseconds(1000); // trigger the left servo
//Now i want the two servos to move back to (1500) immediately, without delay, because I use them to trigger cameras, and once the picture is made , it’s a mess if they don’t stop pressing the shutter button! Anyhow it doesn’t work. wherever I put the two green code-lines below (1)&(2), even with “delay()” statements
digitalWrite(ledPinR, HIGH); // turns the RedLED on
delay(100); // wait for a 10/second
digitalWrite(ledPinR, LOW); // turn the RedLED off
delay(100);
myservoR.writeMicroseconds(1500); // (1)back to central position
myservoL.writeMicroseconds(1500); //(2)
}
else
{digitalWrite(ledPinV, HIGH);
digitalWrite(ledPinR, LOW);
}
}
The point is what I have written as comment. Should i rewrite all the code? I think it doesn’t work because it’s still inside the loop, but I’m rather as newbie with the Arduino code. I’ve certainly overseen something.
Thanks a lot for any help