Go Down

Topic: **Solved** Need help with figuring out why servos not working as intended (Read 700 times) previous topic - next topic

Thevolget

I'm working on a little project for a vehicle that's going to be controlled from a PSX controller while sitting inside for a event.  I've built up the code from writing sections at a time.  When each section is tested the sections work great and don't have any issues.  When I combine the code to the entirety, the motor controls work great, however the servo controls fail to operate.  I'm stumped on why it's not triggering the servos when done.

It's a small vehicle, with Arcade drive (One Joystick controls the motors for turning and throttle) and servos for control of a couple small arms (pan/tilt for shoulder movement using joystick and elbow using buttons).  The current way it's set up is that the Left Analog stick on the PSX controller will control the throttle, the right stick will control the arm pan/tilt (only when either the left or right dpad is held as well), and the shoulder buttons will control the movement of the elbow (L1,L2,R1,R2).

I'm currently using the Adafruit Servo Shield for the servos and a generic motor controller that can handle up to a 50A load per bridge.  Below is the code that i'm running when all of the functions are written in (which all function as intended when run separately).  I've attached the code (plain text file).

Thevolget

I managed to get it working.  I had a bit of a blond moment and after looking into the code after having some sleep, I noticed that I had forgotten to initalize the Servo Shield's I2C interface.  Adding a simple 'pwm.begin();' in the setup function fixed it and now it's working as intended.


JimboZA

Excellent news... amazing what sleep can do.

Might be an idea to edit the first post and stick [solved] or similar at the start of the title.
Johannesburg hams call me: ZS6JMB on Highveld rep 145.7875 (-600 & 88.5 tone)
Dr Perry Cox: "Help me to help you, help me to help you...."
Your answer may already be here: https://forum.arduino.cc/index.php?topic=384198.0

Go Up