Greetings from California!
I understand that this topic has been discussed heavily but I'm still having some trouble with joystick control. My project is a 5 axis robot arm with each axis being controlled by a servo motor (5 axis = 5 servos, 1 servo per axis, you get it). What I want is to use 2 PS2 style joysticks to control the 4 main axis's of the arm (base, shoulder, elbow, and wrist. The 5th servo will open or close the gripper which I may use the button feature for). I've been looking into code to do this and have found some code examples that get me close to achieving my goal; however, the problem is that because the joysticks are spring returned the servos will snap back to the center position. Therefore, I have to hold the joystick to keep the servo in the desired position. Here is the example code that shows what I'm talking about above:
servo C.4, 150
do
readadc C.1, b0
b1=150*b0/255+75
servopos C.4, b1
loop
Again with this code, a servo will move in the direction indicated from the joystick but once the joystick is returned to the center the servo returns to its center position which is not desirable for my application.
Can anyone help me write a code where the servo will move in the direction that the joystick is moved but the servo will not snap back to center when the joysick is back at its center? Is this even possible to do? Thank you all in advance!
I understand that this topic has been discussed heavily but I'm still having some trouble with joystick control. My project is a 5 axis robot arm with each axis being controlled by a servo motor (5 axis = 5 servos, 1 servo per axis, you get it). What I want is to use 2 PS2 style joysticks to control the 4 main axis's of the arm (base, shoulder, elbow, and wrist. The 5th servo will open or close the gripper which I may use the button feature for). I've been looking into code to do this and have found some code examples that get me close to achieving my goal; however, the problem is that because the joysticks are spring returned the servos will snap back to the center position. Therefore, I have to hold the joystick to keep the servo in the desired position. Here is the example code that shows what I'm talking about above:
servo C.4, 150
do
readadc C.1, b0
b1=150*b0/255+75
servopos C.4, b1
loop
Again with this code, a servo will move in the direction indicated from the joystick but once the joystick is returned to the center the servo returns to its center position which is not desirable for my application.
Can anyone help me write a code where the servo will move in the direction that the joystick is moved but the servo will not snap back to center when the joysick is back at its center? Is this even possible to do? Thank you all in advance!