I am a complete beginner.
i have compiled a code for arduino uno board and i am not sure if i am doing it right.. so if any help will be aprriciated. somehow, i have managed to open the the retracts and are currently in 90deg position. i cant seem to make it go back to its original, 0deg position.
// the following if statement is to open the gripper or the servoless retracts landing gear
if (zerovalue == 1)
{
Serial.println("2000");
myservo.writeMicroseconds(2000);
myservo2.writeMicroseconds(2000);
}
// the following statement is to close the gripper or the servoless retracts landing gear
else if (ninetyvalue == 1)
{
Serial.println("1500");
myservo.writeMicroseconds(1500);
myservo2.writeMicroseconds(1500);
}
Simple servo test code you can try with your servos using the serial monitor. Note that most RC receivers output control pulses in the position range of 45-135 deg. You can also connect bith signal wires to the same arduino signal output pin. Also note the caution about powering servos from the arduino.
//zoomkat 7-30-10 serial servo test
//type servo position 0 to 180 in serial monitor
// Powering a servo from the arduino usually *DOES NOT WORK*.
String readString;
#include <Servo.h>
Servo myservo; // create servo object to control a servo
void setup() {
Serial.begin(9600);
myservo.attach(9);
Serial.println("servo-test"); // so I can keep track of what is loaded
}
void loop() {
while (Serial.available()) {
char c = Serial.read(); //gets one byte from serial buffer
readString += c; //makes the String readString
delay(2); //slow looping to allow buffer to fill with next character
}
if (readString.length() >0) {
Serial.println(readString); //so you can see the captured String
int n = readString.toInt(); //convert readString into a number
Serial.println(n); //so you can see the integer
myservo.write(n);
readString="";
}
}
so i am using this simple code to see if my retracts can continuously go up and down. but both of the retracts are in 90deg and can hear ticking sound in the motor but its not going down.
#include <Servo.h>
Servo myservo;
Servo myservo2;
void setup()
{
myservo.attach(9);
myservo2.attach(11);
// myservo.writeMicroseconds(1500); // set servo to mid-point
}