I've fixed a couple of running bugs with the data packet, and I've modified the NXTI2CDevice library to be compatible with Arduino 1.0.
The attached zip file has
1. a new Arduino sketch
2. a new Processing sketch
3. the modified NXTI2CDevice library
You'll still need the Procontroll library in Processing, though.
Greetings, everyone, and welcome to my first instructable!
Today we'll be covering a few major bases to get to the final goal: controlling an Arduino-based robot via a PS3 remote! By the end of this instructable, you'll be able to control the speeds of both NXT motors with the two analog sticks of a PS3 controller.
Here's the idea:
A PS3 communicates via bluetooth to the computer sending the value of its analog sticks to the Processing program. Processing then sends this information as a packet of data to the Arduino bot through the Xbee wireless modules. Lastly, the Arduino board "unpacks" this data packet and interprets it as the speed and direction to drive each motor.
Here are the three basic milestones that we'll cover:
-- using Arduino to control NXT Motors
-- interfacing the Programming Language Processing with a PS3 controller
-- Wireless communication between your computer and Arduino via Xbee modules
If you aren't quite comfortable with either Processing or Arduino's Programming languages--fear not! I've accompanied the project with my source code .
Here's what I'll assume:
-- you're mildly familiar with Arduino, and you can a user-created library to the IDE.
-- your computer has bluetooth-pairing capabilities
-- you can strip a few small wires and you have basic soldering skills.
Here's a few concepts that you'll learn about on the side:
(You don't need to know about these beforehand to get started on this project)
-- Xbee wireless communication
-- i2c communication (between the NXT motors and Arduino)
All right, Let's get started!
Lastly, feel free to check out the video for the final results of this project in action!
Remove these ads by
Signing UpStep 1: Materials
I got the hard-to-find (nonLego) pieces from both Sparkfun.com and Mindsensors.com
Robot Materials:
-- two Mindstorms NXT Motors and two cables
-- Lego Technic Pieces to build your robot Chassis
-- Standard Arduino (I used the UNO. This actually allows me to skip adding pull-up resistors to the analog inputs)
-- 9V batter and 9V battery Clip to power the Arduino. ( We could power it off the motor battery, but I'll hold off on that to keep it simple.)
-- Battery Pack (or other power supply. I'm using a 7.2V NiMH pack)
-- I2C Host Cable with NXT Connector
-- Tape (Gaffer's Tape is probably the least messy, but any tape will do the job)
http://www.mindsensors.com/index.php?module=pagemaster&PAGE_user_op=view_page&PAGE_id=136
-- Multiplexer for NXT Motors (this piece gives us the ability to speak to the NXT motors lots of ugly wire snipping)
http://www.mindsensors.com/index.php?module=pagemaster&PAGE_user_op=view_page&PAGE_id=134
Communication Materials
-- 2 XBee 1mW Wire Antennas (Xbee radios)
http://www.sparkfun.com/products/8665
-- XBee Explorer USB connector
http://www.sparkfun.com/products/8687
-- XBee Wireless Shield
http://www.sparkfun.com/products/9976
Other Hardware:
-- header pins (longer header pins are a bit more user-friendly)
-- PS3 controller
-- mini USB cable for connecting the Xbee to your computer
-- USB cable to program the Arduino
A bundle of OpenSource Software:
-- The Arduino IDE
http://arduino.cc
-- Processing
http://processing.org/
-- The NXT Library for speaking to the NXT i2c Motors
https://launchpad.net/nxti2cdevice
(Side note: This NXT Library is a great project all to itself! Check out the man Clinton Blackmore behind the accomplishment at http://robotclub.ab.ca/ )
-- The Processing Language Library called Pro Controll which will allow us to communicate with the PS3 controller.
http://creativecomputing.cc/p5libs/procontroll/
Final Tools to get the job done:
-- Soldering Iron
-- Solder
-- Exacto knife (or any small-and-precise knife)
-- wire strippers for stripping very thin wire.








































Visit Our Store »
Go Pro Today »




I keep hearing you say that you want to figure out if you can do this or that...can you please actually do it? Range doesn't matter to me, so Can I or Can't I directly bluetooth the Ps3 controller to an arduino shield?
Thanks, but I really just need some way to take Ps3 controller stick movement and tie that to analog output pins on arduino. Can I cut out all of the wireless, just for a start?
Thanks,
Sjors
So this means that i cannot controll my robot without a computer/laptop as a middle-man? I always have to take my laptop with me to controll the robot?
We're building a remote controlled hovercraft, and we'd like to controll it with a ps3 controller. We know the range of the ps3 controller isn't that far, but we can walk after the hovercraft when controlling, that's not a problem. But do we have to take our laptop with us too, to controll it properly?
Many thanks for the fast reply,
Sjors
Failed to poll device: Failed to poll device (8007000c)
Failed to poll device: Failed to poll device (8007000c)
0
0
0
0
<<< available PLAYSTATION(R)3 Controller sliders: >>>
0: Z Rotation absolute
1: Z Axis absolute
2: Y Axis absolute
3: X Axis absolute
4: Pointer absolute
<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<<< available PLAYSTATION(R)3 Controller buttons: >>>
0: Button 0
1: Button 1
2: Button 2
3: Button 3
4: Button 4
5: Button 5
6: Button 6
7: Button 7
8: Button 8
9: Button 9
10: Button 10
11: Button 11
12: Button 12
13: Button 13
14: Button 14
15: Button 15
16: Button 16
17: Button 17
18: Button 18
<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Exception in thread "Animation Thread" java.lang
.NullPointerException
at Test.draw(Test.java:60)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:662)
It looks like the driver is telling the proCONTROLL library that there are buttons or some other method of input that actually doesn't exist.
At this point, can you actually see the "paired" bluetooth symbol if you try to connect the controller to your computer?
http://www.ebay.co.uk/itm/Ansmann-RC-Car-7-2v-3000mah-Battery-Delta-Pro-Charger-/280716528572?pt=UK_ToysGames_RadioControlled_JN&hash=item415c024bbc
please reply ASAP!!!
http://www.ebay.co.uk/itm/RC-Ansmann-Male-Tamiya-Battery-Connector-5pcs-ESC-wire-/260817463004?pt=UK_ToysGames_RadioControlled_JN&hash=item3cb9eea6dc
I actually built the robot chassis using spare lego technic parts. The chassis itself doesn't matter for this instructable, so feel free to build your own, as long as it uses two nxt motors: one for each side of the robot.
Don't forget that you'll also need the multiplexor board to connect the motors into the cable also! You can find that here:
http://www.mindsensors.com/index.php?module=pagemaster&PAGE_user_op=view_page&PAGE_id=134
Have fun, and i'd love to here how it goes!
jsut need to orderthe stuff now.Could u please help me with processing (controller test)
=============================================================
Failed to poll device: Failed to poll device (8007000c)
Failed to poll device: Failed to poll device (8007000c)
0
0
0
0
<<< available PLAYSTATION(R)3 Controller sliders: >>>
0: Z Rotation absolute
1: Z Axis absolute
2: Y Axis absolute
3: X Axis absolute
4: Pointer absolute
<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<<< available PLAYSTATION(R)3 Controller buttons: >>>
0: Button 0
1: Button 1
2: Button 2
3: Button 3
4: Button 4
5: Button 5
6: Button 6
7: Button 7
8: Button 8
9: Button 9
10: Button 10
11: Button 11
12: Button 12
13: Button 13
14: Button 14
15: Button 15
16: Button 16
17: Button 17
18: Button 18
<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Exception in thread "Animation Thread" java.lang
.NullPointerException
at Test.draw(Test.java:60)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:662)
:( :(
http://www.youtube.com/watch?v=y5LiI4uGXNk
(I will make the changes in the instructable itself also. Thanks for catching this!)
Also, I haven't yet looked into drivers for the PS3 controller on systems other than MacOSX to create instructables for them. I don't have a Windows system to try them out.
You might have some luck here though:
http://hackaday.com/2009/01/11/windows-drivers-for-ps3-controllers/
In your case, I'm doubting that your motors will have the same interface as the I2C interface on the NXT motors.
You'll need to find some way of communicating with the motors. Usually, this involves clipping the motor wires and wiring them up to an H-bridge. Then, the arduino communicates to the H-bridge instead.
There are quite a few examples online of how to do this. Here are a couple good places to get started:
http://www.mcmanis.com/chuck/robotics/tutorial/h-bridge/
http://itp.nyu.edu/physcomp/Labs/DCMotorControl
http://www.instructables.com/id/Control-your-motors-with-L293D-and-Arduino/#
http://www.societyofrobots.com/member_tutorials/node/164
I hope that this helps!
(I'm not sure of any retailers that aren't online.)
Online, though, shouldn't be a problem.
you can find them on
sparkfun.com
or
http://search.digikey.com/scripts/DkSearch/dksus.dll?Selection
or
http://www.robotshop.com/ProductSearch.aspx?qs=xbee
I'd recommend Sparkfun because they also sell the other components that this instructable uses.
In my case, because the kind folks who created the proControll library were able to interface with a PS3 controller via Processing, and because Processing can send signals via a serial connection, I just took the project a step further by making a wireless serial connection between the computer and the Arduino via Xbee radios.