Let's Make Robots!

Multiple JoySTick/Potentionmeter Problem

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

rotateleft:
servo 0, 75
goto main

rotateright:
servo 0, 225
goto main

shoulderup:
servo 1,75
servo 2,75
goto main

shoulderdown:
servo 1, 225
servo 2, 225
goto main

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Hi Jaryd,

 

This code should allow you to move arm slowly and stop in any position

 

symbol less = 100
Symbol more = 150
symbol basepos =b11
symbol armpos = b12
let basepos = 150
let armpos = 150

main:
readadc 0, b0
if b0 < less then
gosub rotateleft
endif

if b0 > more then
gosub rotateright
endif

readadc 3, b3
if b3 < less then
gosub shoulderup
endif

if b3 > more then
gosub shoulderdown
endif

pause 10       REM for slower movement
goto main

rotateleft:
let basepos = basepos - 1 min 75
servo 0, basepos
return

rotateright:
basepos = basepos + 1 max 225
servo 0, basepos
return

shoulderup:
let armpos = armpos - 1 min 75
servo 1,armpos
servo 2,armpos
return

shoulderdown:
let armpos = armpos + 1 max 225
servo 1, armpos
servo 2, armpos
return

thanks,