Welcome to Synthiam!

The easiest way to program the most powerful robots. Use technologies by leading industry experts. ARC is a free-to-use robot programming software that makes servo automation, computer vision, autonomous navigation, and artificial intelligence easy.

Get Started
Asked — Edited
Resolved Resolved by Niek!

Connecting An Analog To Ez-B To Control Robot

is it possible to put an analog stick to an ez-b through the A0,A1...... ports

User-inserted image

By setting up variables to the x,y and button press (vert, horz, sel) is it possible to setup if statements for controlling the robot ex:


$Vertical = A1
$Forward = D1

If $Vertical = 1
$Forward = On

sorry code is incorrect have forgotten a few of the terms, since i have been using Java and C++ for the last few months and everytime I start using other languages i need a quick recap of the other languages.


Upgrade to ARC Pro

ARC Early Access will give you immediate updates and new features needed to unleash your robot's potential!

AI Support Bot
Related Content
@kplamondon yes it's definitely possible to hook up an analog thumbstick directly to the EZ-B analog ports (well as long as you still supply the breakout board with 5V and GND).

Most of us usually use a wireless gamepad hooked up to the PC/Laptop in order to wirelessly control our robots (via a Joystick control) but I'm sure you have a unique application in which you need a tethered connection.

As for the code, you are on the right track just check the settings menu under any EZ-Script control to see the list of commands and functions available to you.
ok thats good to know, now my second question is how to connect to the Joystick Board of a Wireless "Icon" PS2 Controller. I have all the connections figured out accept for AD which connects to 2 pins on each of the potentiometers. (2 Left)
User-inserted image

What I am most confused about is that the 2 pins are side by side pins, normally the 2 outside are GND and 5v while the middle (not outside right) is the X/Y Analog pins. Having the 2 outside ones could indicate some complex power source with the Icon Controller. I am really curious how the connection works with the AD pin, specially since V+ is actually 5v coming out of it, VM is power to the vibration if the switch is on (mine didn't come with vibration so it and the switch are empty) and the 2 GND's connect to each other via the wire beside the ports.

Also notice (if the picture is clear enough) RX (right horizontal) is said twice and no RY is wrote meanning one is RX and the other is RY, but it was printed wrong.


VM - useless without vibration
G- - GND is connected to the other GND (the main GND attached to the battery)

AD - ?
L3 - button when clicked ----> Digital Port (input)
LY - Left Vertical -----> Analog port
LX - Left Horizontal ---> Analog port
RX - [Right] Either Horizontal or Vertical -------> Analog Port
RX - [Right] Either Horizontal or Vertical -------> Analog Port
R3 - Right Button ------> Digital Port (input)
V+ - 5v output (probably went to power the rest of the controller and then came back through GND)
G- - GND the main ground that connects straight to the batteries ground wire

if I can't connect to this i am not sure if it will work with the board shown earlier since the connections are different from normal (Sony might make them the same as the board), see the board schematic
United Kingdom
Hi I think you are making yourself a lot of work here as Skater says ARC has a great joystick function and you would normally plug your Joystick into the USB port of the controlling PC and press the buttons to see what button maps to the commands you want or what servo you want to control or even what variables you intend to use in your program. It will work with a variety of joysticks. You can even use a Nintendo Wii which connects via Bluetooth.

I think you need to help us out here if you want to do something different? than just connect a joystick via the EZB board

check out this tutorial
my robot is not that simple @winstn60. I am building a rover that uses XBees for long range (controller is connected to Xbee which is sent to EZ-B with onboard computer. In order for a great distance the controller must connect to the XBee. This can't be done by plugging your controller into a computer when the computer is a killometre away from you. In addition to that XBee uses serial communication, using bytes (22 or 23 in total) these are all in hex values ex: 2e08 which requires a little more complex procedures to communicate with eachother then the bluetooth module on the EZ-B since for one the serial communication EZ-Robot Team took care of and also it only uses the RX/TX, XBee also has inputs (which can become outputs when sending certain serial data and hex values) which in API mode it requires a lot of Hex calculations to communicate and tell eachother the data that they are sending.

Also the robot has buttons and analogs that are attached to the robot to go through the different tasks that it can do which is viewed on a graphical lcd screen. Ie you can select through the modes for obstacle avoidance, moods, voice command (took many hours of coding all the terms for this (as for i used an actual voice module that decodes what you speak into Hex values (measuring freaquenzies/volume of your voice) this then sent to 2 digital ports 1 which gives the volume of the voice when spoke and the other gives you the string variable of what is spoken. This is beneficial because it can be sent from the controller with the xbee to the robot with the ez-b. It also has harmfull gas detection, one of the main reasons to the robot (this is done by interfacing an H2s monitor with analog ports for each gas detection (4) the analog ports read the voltage coming from the detector which each detector (almost any type) has three connectors, just like the common joystick's potentiometers, 5v, analog output, GND.

I know about all the features ez-b has, and i know the scripting for it too. As for i am not using the graphical version of the software either, that is why this forum is under scripting and not general questions.

But don't get me wrong, I wish it were that simple to connect to my robot, but it is not. I either have to use the board the controller came on, if i can, or the board in the first post, which may require different joysticks. Thanks for the input, i really do appreciate feedback from people but my project is to complex for that, I might even have to put an arduino micro inside the controller to read the analog values and send it to the ez-b through XBee Serial Comunication, as for their may not be enough Analog and Digital inputs on the XBee for the number of buttons and analogs it will contain, and a second ez-b would take up to much space in the controller, third it would require another computer for the ez-b in the controller since the other computer can be 3.2km away with XBee distance.

My biggest concern with these joysticks is how they work, as for the potentiometers seem to have a different wiring system from the most common (5v, A-Output, GND).

I did some research, and it seems that the PS2 controller joystick is also just 2 potentiometers. The base of each joystick should have 3 leads for each pot. The outsides should be 5v and gnd, and the inside is the analog output. Try to find other points on the PCB that you're certain of that they're power and ground and use those to trace the connections.

I found this image on the internet, and indicated the potmeter connections on it.
User-inserted image

Hope this helps:)
this is what i figured was happening but my controller is not an official sony controller (which could be differant) and in the picture you will see you can hook up to ports off the board it is on. I have looked inside a sony controller and you are completely right, as for this controller is still to potentialmetres but for some reason they are hooked up weired on the board, instead of 5v Analog GND its got the 2 connected together under AD and 1 from each potentialmetre goes to RX/RY/LX/LY.

User-inserted image

User-inserted image

User-inserted image
Those 2 leads put together, are they connected to VCC or GND?

And in the other controller board, are there any resistors on the XY etc lines?
The first picture is the backside of the other 2 pictures, not sure if thats what you mean in other board, if so i don't see any on the board or if you are reffering to the top post then the answer is no, it just connects the 5v and GND pins from the 2 potentiometers. But i see what you mean which would make more sense if there was a resistor.

If you follow the backside of the board you will notice the 2 pins on each potentiometres are connected to eachother, these are all on the AD pins, then the third pin goes sepparately to the RX,RY,LX,LY.

The AD pin is the mystery, AD i would think would stand for an analog input or output but i am unsure.

Here is the 1st boards wiring: here

EDIT: if you mean the board with the buttons etc, their might be resitors on their that the AD is connected to
@kplamondon with other board, I mean the rest of your ps2 controller. Could you trace what AD is going to on there?
Visuals are always nice so heres a bunch of pictures, the AD goes to the middle wire on the R1 and R2 (L1 and L2) buttons, the wiring there is R1, JP4, R2 it also goes through all the buttons on the Left and all the Button on the Right. Whatever AD is it goes to every button and potentiometre, either 5v or GND but i am still unsure but it does connect to all the buttons and maybe R23 i am unsure.

User-inserted image

User-inserted image

User-inserted image

User-inserted image

User-inserted image
I think I have an idea how to connect them up to the EZ-B. Could you measure the resistance between the outer terminals in 3 positions? All the way to one side, to the other and centered.
sorry about not replying have been gone for the past 3 days, i will measure this tomorrow. But how specifically do you want to measure the resistance, send power and use a volts metre or measure ohms? I am not totally sure what you mean, if you can be more specific on the connections i should be able to measure some connections.
Just hook up a multimeter to the outer two leads, set it to measure ohms and measure the resistance when the potmeter is to one side, to the other and centered. This helps me determine how to hook it up to the EZ-B, if you should use external pullups/downs etc.
Ok i measured the ohms resistance, although the numbers were jumping around the more i tested, under ohms 2000 the values were: centre 65, down 90, up 41. They changed a bit do to trying to put the ends of the multimetre on soldered ends but i am sure the differance between the values would be similar. A few times i measured centre around 55-65 but my last was 65.


Up = 800 resistor
Centre = 1.3K resistor
Down = 1.8K Resistor
also i found a blog where someone used the same controller as me and was able to use the joystick board that the joysticks are on. check it out pg I, pg II, pg III.

See if you can figure out what he did, he doesn't explain much but he cut out a breadboard to fit and managed to hook it all up to that. I don't really need any of the buttons, which i can already hook those up on my own. But the analogs he was able to hook up to that board he made.
@kplamondon Thanks, I'll make you a schematic in a couple of days.

The guy you linked just created his own board with tactile switches (on/off, no in between). It's easy to hook up to the EZ-B, but takes up lots of IO.
thanks a lot, if you can show a schematic that would really help, I'll be able to visualize what you want me to do. I can't wait to get the analogs hooked up.
How's the schematic coming, haven't heard from you in a while. I have been playing around with potentiometres lately (practicing making script for joysticks) managed to get the robot moving forward, stop, or back depending on the value of the potentiometre. The joysticks will be very much similar to the potentiometre, only more directional code to right EX: setting it up for both turning by using one wheel reverse and the other forwards as well as gradual turns by making one side slower then the other.
@kplamondon I'm hosting a polish exchange student so I've been kinda busy;) It's good that you started figuring it out on your own!

I finished the schematic yesterday, just writing some example code for you. I can't send the schematics, but it's basically just hooking the AD up to 5V and for every RX, RY etc connect the pin to a analog port and use a 1.3K pulldown resistor. Then you can just write a sketch that constantly prints the analog values of those pins to the console to find out the positions.
Thats great, is the schamatics computer or drawn. You could always screen shot off the program, or email me the files at Kyle.Plamondon@gmail.com (don't currently have software but have been planning to get one, deppending on price of AutoCAD) if drawn you can always scan and put on here or email to me.

As for the example code i can't wait to see, thanks alot for your help so far.
Hi Kyle,

I finally had time to finish the schematic and code. Here's how you hook it up. Do the same for RX, RY etc.
User-inserted image

The joystick's resistance is 1.3K when centered, so with the 1.3K pulldown it should divide the voltage in half. ARC's getADC function returns a value between 0 and 255 for 0-5V. This means that centered, it should be around 127. Up it should be around 158 and down 107. The value might fluctuate quite a bit so the code should have tresholds. This means you end up with something like this:


# Potentiometer joystick script
# Written by Niek Blankers

$value = getADC(adc0) # Change 'adc0' to used analog port
$centerValue = 127 # The potentiometer's value when centered
$treshold = 10 # Up/down treshold

# Check the position
If($value - $centerValue > 30) # Up

Print( "Up" )
ElseIf($centerValue - $value > 30) # Down

Print( "Down" )
Else # Centered

Print( "Center" )

Now use this code for every axis and you should be fine:)
thanks a lot, i will try this out soon. My goal is to make a microchip in the same shape as the button microchip. In this case i will build a schamatic of the microchip using your method and have all the resistors/components needed on it.
Thanks so much this will help a lot, i got lots of work to do on my own still but at least i know what to do now.

What software are you using to build schamatics, Eagle? B/c i just bought it, and i seen the video with you designing a for the EZ-B that can be programmed using Arduino (which i think is a great idea), what was that software? It didn't look like eagle, I'm knew to designing PCB's.
kplamondon , looks like the community was able to find some really great information for your project. I hope it's all helpful! Do you mind marking the thread as answered/ resolved. Thankyou! - Josh
@kplamondon I might be a bit late with this, but you should test it out on a breadboard first:D

I am using Eagle CAD, yes. There are lots of great tutorials for it out there. The software Jeremie over at EZ-Robot is using was Altium.