So, i have a robotic arm project that i am working on. I decided to use a joystick from a playstation 2 controller to control it. I extracted the joystick and wired up the potentiometer. When i use 1 potentiometer(to turn the base left and right) it works 100% correctly. However, when i try to add a second potentiometer/ joystick it doesnt work right. The second joystick will control the base not the shoulder that i want it to control. The code i use is below. I am using the picaxe 28x1 board.
Symbol less = 100 Symbol more = 150
main: readadc 0, b0 if b0 < less then gosub rotateleft else endif
if b0 > more then gosub rotateright endif
readadc 3, b3 if b3 < less then gosub shoulderup else endif
if b3 > more then gosub shoulderdown else endif goto main
I tried the code that jinx posted but right now i couldnt get it to work. Anyway, i revised my code and this is what i got(below). Now, i can use the x and y axis of one joystick. It works ok. When i rotate the base. It works perfectly. When i go to move the shoulder the base rotates as well although i dont want it to.??? Waiting for more parts… then i will hook up other joystick but overall i have progress.
Symbol less = 75 Symbol more = 175
main: readadc 0, b0 if b0 < less then gosub rotateleft else endif
if b0 > more then gosub rotateright endif
readadc 1, b1 if b1 < less then gosub shoulderup else endif
if b1 > more then gosub shoulderdown else endif goto main
The darlington chip is still in place. Remove it and in its place, add a 330 resistor for each servo output.
Have you done a debug yet? I assume you already did this to see if your numbers are coming in wrong or if they are coming in right and going out wrong. If not, I would.