ok,
you gonna need to make some changes on the code
depending on the code you are using:
change the minimum value (0º) to 5º
change the max value (180º or 175º) to 140º
Use this code to test it out:
and try again, your electric setup is good now, it should work without any problems now.
also, i have a question, are those digital servos?
you gonna need to make some changes on the code
depending on the code you are using:
change the minimum value (0º) to 5º
change the max value (180º or 175º) to 140º
Use this code to test it out:
Code:
#include <Servo.h>
//servo 1
Servo myservo;
Servo myservo1;
int val; // variable for reading the pin status
int val2; // variable for reading the delayed/debounced status
int buttonState;
int servostatus = 0;
int switchPin = 2; // Switch connected to digital pin 2
int ledPin = 5;
void setup() // run once, when the sketch starts
{
//servo 1
myservo.attach(9);
myservo1.attach(10);
pinMode(switchPin, INPUT);
pinMode(ledPin, OUTPUT);
buttonState = digitalRead(switchPin);
myservo.write(5);
myservo1.write(140);
}
void loop() // run over and over again
//servo 1
{
val = digitalRead(switchPin); // read input value and store it in val
delay(10); // 10 milliseconds is a good amount of time
val2 = digitalRead(switchPin); // read the input again to check for bounces
if (val == val2) { // make sure we got 2 consistant readings!
if (val != buttonState) { // the button state has changed!
if (val == LOW) { // check if the button is pressed
if (servostatus == 0) { // is the light off?
servostatus = 1; // turn light on!
myservo.write(5);
myservo1.write(140);
delay(1000);
digitalWrite(ledPin, HIGH);
delay(50);
digitalWrite(ledPin, LOW);
delay(5);
digitalWrite(ledPin, HIGH);
delay(50);
digitalWrite(ledPin, LOW);
delay(5);
// fading
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
delay(30);
}
} else {
servostatus = 0; // turn light off!
digitalWrite(ledPin, LOW);
delay(15);
myservo.write(140);
myservo1.write(5);
}
}
}
buttonState = val; // save the new state in our variable
}
}
and try again, your electric setup is good now, it should work without any problems now.
also, i have a question, are those digital servos?
Last edited: