Hello i am building a robotic arm and i have most of the project complete when i powered it up today i saw a problem that i could not see during testing ... the servos are twitching a lot.
I use an ADS1115 to read the joystick positions and then devide the value to get a range of 0-1024.
I have no idea how to solve the twitching of the servos and if there is another less messy way.
I will post my code below in a pastebin link due to the 9000 characters restriction of the forum.
The function that reads the adc is read_controls()
and the function that drives the servo is drive_servo()
the code seems a bit messy as a whole and a bit simplified because i tried to get it as simple as i could and then fix it up later. Also i work in tabs so that is why it may seem long i use functions to bind all the pieces together.
Edit : I corrected the drive_servo function to remove the claw servo from it due to the use of the separate claw servo function.
Anyway thank you in advance.
Hi,
Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html
Attach it as a ino file to your next post.
What model Arduino are you using?
Why aren't you using the Arduino on board AtoD?
You could have a problem with the timer/interupt that the two libraries may use.
Try SoftwareServo library.
https://playground.arduino.cc/ComponentLib/Servo
Tom.. 
Here are the .ino files.
I do not use the onboard ADC because i need a 4 wire connection between the controller (which has the joysticks on) and the mcu
I use this ADC ADS1115 and this servo controller from adafruit Pwm I2C module and the board is a Arduino Nano
So that all my peripherals communicate using the I2C protocol with the mcu
Edit : Also from what i see when i power the arm is that the problem lies within my code in the servo delay variable the motors are working but they are making fast moves.
Arm_sketch_v10.7.ino (1.26 KB)
drive_claw.ino (332 Bytes)
drive_servo.ino (11 KB)
drive_stepper.ino (501 Bytes)
home_stepper.ino (286 Bytes)
read_controls.ino (1.41 KB)
variables.h (1.14 KB)