TomGeorge:
Hi,
OPs pic;
Very nice.
Servos can be a doddle.
- Servos can require more an an AMP to run, check specs.
- Servo needs separate supply from the controller.
- The Controller gnd MUST be connected to the Servo Supply gnd.
- Servos consume current even when signaled to a fixed position if the servo has to work against a load torque.
- The cheaper the servo, the less each servo behave to spec, in particular, 0 to 180, might be 10 to 170.
Tom...![]()
I can make one spin at will...............lol
The problem is I have built a parrot. Yes a mechanical burd... It has 4 kit servos (SG90s) I had to install as the build went on and are now inaccessible. How did I know they dont actually start at 0 Lol..........
I need two to run off a joystick (look left and right/ Look up and down).
I need one to run off the press button in the joystick (mouth open and close) and one separate button to flap the wings.
The nearest I could find program wise was this with lines added for the 'W' axis but Im having trouble getting rid of the serial monitor bit. everytime I try and delete it the damn thing wont verify. If I leave it in the damn thing comes up with faults on my W axis. Its driving me to distraction.
Projeto Arduino - Como ligar um joystick no Arduino
----------------------------------------
--=<| www.ComoFazerAsCoisas.com.br |>=--
----------------------------------------
*/
// including library for servomotor control
#include <Servo.h>
//Creating a Servo Class Object
Servo servoMotorObjX;
Servo servoMotorObjY;
Servo servoMotorObjZ;
Servo servoMotorObjW;
//pin (PWM) associated with servomotor control
int const servoMotorX = 4;
int const servoMotorY = 5;
int const servoMotorZ = 3;
int const servoMotorW = 2;
//stores the read position
// on the joystickstick axes
int joystickX = 0;
int joystickY = 0;
int joystickZ = 0;
int joystickW = 0;
//Assigning the analog pins
int axisX = A3;
int axisY = A2;
//Assigning the digital pins
int axisZ = 9;
int axisM = 8;
void setup() {
//associated with the digital control pin of the
// servo to the Servo class object
servoMotorObjX.attach(servoMotorX);
servoMotorObjY.attach(servoMotorY);
servoMotorObjZ.attach(servoMotorZ);
servoMotorObjW.attach(servoMotorW);
// Defining Z and M axis as an input pin
pinMode(axisZ, INPUT);
pinMode(axisM, INPUT);
servoMotorObjX.write(80);
servoMotorObjY.write(80);
servoMotorObjY.write(170);
servoMotorObjW.write(170);
// Activating the Serial Monitor that will display the
// values ββread on Joystick
Serial.begin(9600);
}
void loop() {
// Read the value of the X axis
joystickX = analogRead(axisX);
// Read the value of the Y axis
joystickY = analogRead(axisY);
// Read the value of the Z axis
joystickZ = digitalRead(axisZ);
// Read the value of the W axis
joystickW = digitalRead(axisW);
printAxis();
// mapping the value read on the joystick to the scale of the
// servo (between 0 and 180)
joystickX = map(joystickX, 0, 1023, 0, 180);
joystickY = map(joystickY, 0, 1023, 0, 180);
joystickZ = map(joystickZ, 0, 1, 0, 180);
joystickW = map(joystickW, 0, 1, 0, 180);
// defining the value / position of the servomotor
servoMotorObjX.write(joystickX);
servoMotorObjY.write(joystickY);
servoMotorObjZ.write(joystickZ);
servoMotorObjW.write(joystickW);
// wait 20 milliseconds.
delay(20);
}
// This method is responsible only for printing on the
// Serial Monitor the values ββof the X, Y and Z axes.
void imprimeEixos() {
//imprime o valor do eixoX
Serial.print(" X=");
Serial.print(joystickX);
//imprime o valor do eixoY
Serial.print(" Y=");
Serial.print(joystickY);
//imprime o valor do eixoZ
Serial.print(" Z=");
Serial.println(joystickZ);
Serial.print(" W=");
Serial.println(joystickW);
}
I dont think it helped it was in Portuguese ![]()
What do you think........... Am I onto a loser ![]()

