hi there.
I’m having trouble figuring this out.
How can i program a joystick to turn a relay on forward when it goes beyond a certain point (say beyond 147) and backwards when in the opposite direction (beyond for example) and then when the joystick is neutral, the relay is off. We are trying to get a joystick (port 4) to control our piston that moves the arm up and down (relay 6)
Thanks
Well, the easiest solution would be:
relay6_fwd=0
relay6_rev=0
if p4_y > 147 then
relay6_fwd=1
else
if p4_y < 107 then relay6_rev=1
endif
If p4_y > 147 Then
'lift arm up
relay6_fwd = 1
Else
If p4_y < 100 Then
'lower arm
relay6_fwd = 0
Else
'do nothing
Endif
Endif
Note that the above code is from memory and I may have the variable names a bit mixed up.
Also, I don’t know how your robot is plumbed. It may be that I don’t turn on the relays in the right order or direction or maybe even you use an exotic combination of valves and such that you need to do more that what I suggested to put the arm up or to lower it. But… … you should be able to figure things out from the code example. Also, you probably need to have something initializing the position when the robot resets or is powered up just to be sure that you are in the state you want to be in when you wake up.
Good luck.
Joe J.