Hello all, I recently had to switch from the Sunfounder servo (180 degrees) to a Feetech FS5106R continuous servo. Im using the HCPCA9685 break out boards to provide better power and control to the servo. Previouosly, I Used a Joystick to control certain angles of a servo so that I can move it with in a given area, i got a servo bracket designed for the Feetech FS5106R so I removed the Sunfounder servo and put it in the Feetech but it keeps rotating. How can i Prevent this from happening? Below is my code
/* Arduino Multiple Servo Motors Control Using The PCA9685 PWM Module VERSION 1 PROPORTIONAL
Created by Yvan / https://Brainy-Bits.com
This code is in the public domain...
You can: copy it, use it, modify it, share it or just plain ignore it!
Thx!
*/
#include "HCPCA9685.h" // Include the HCPCA9685 library created by Andrew Davies
#define I2CAdd 0x40 // Default address of the PCA9685 Module
#define JoyX A0 // Joystick X pin connected to A0 on the UNO
#define JoyY A1 // Joystick Y pin connected to A1 on the UNO
// Used to store the mapping of the Joystick X and Y values
int ServoXforward;
int ServoXbackward;
int ServoYforward;
int ServoYbackward;
HCPCA9685 HCPCA9685(I2CAdd); // Define Library to use I2C communication
void setup()
{
Serial.begin(9600);
HCPCA9685.Init(SERVO_MODE); // Set to Servo Mode
HCPCA9685.Sleep(false); // Wake up PCA9685 module
}
void loop()
{
int val1X = analogRead(JoyX); // Read current value of Joystick 1 X axis
int val1Y = analogRead(JoyY); // Read current value of Joystick 1 Y axis
// Map Joystick Axis values to servo Min and Max position
ServoXforward = map(val1X, 0, 1023, 402, 10); // Move servo 15
ServoXbackward = map(val1X, 0, 1023, 10, 820);
ServoYforward = map(val1Y, 0, 1023, 10, 820);
ServoYbackward = map(val1Y, 0, 1023, 820, 10);
// Move Servos to read postion from Joystick
HCPCA9685.Servo(15, ServoXforward); // Move Servo 15
{
Serial.println("pot below");
Serial.println(val1X);
delay(300);
Serial.println("Servow below");
Serial.println(ServoXforward);
delay(300);
}
Thank you for any help