Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: JSH21 on August 03, 2008, 10:12:58 PM

Title: Arduino PS2 Controller
Post by: JSH21 on August 03, 2008, 10:12:58 PM
Hi can you connect an Arduino Diecimila board to a ps2 controller so you can control the servos you have attached to it?
Title: Re: Arduino PS2 Controller
Post by: sonictj on August 04, 2008, 03:37:58 AM
I just checked the arduino forum and found this http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1203744779 (http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1203744779).

you could also do what I do, which is use  Glovepie to emulate keyboard presses to control the arduino.  http://carl.kenner.googlepages.com/glovepie (http://carl.kenner.googlepages.com/glovepie)

works with wiimotes ,the ps3 sixaxis and a few other controllers I think.

 
Title: Re: Arduino PS2 Controller
Post by: JSH21 on August 04, 2008, 11:11:57 AM
Cool thanks very much :)
Title: Re: Arduino PS2 Controller
Post by: sonictj on August 04, 2008, 01:15:36 PM
if you use glovepie you will want to map out buttons with both a key and a enter press.

*example
when the wiimote's "a" button is pressed keyboard "a" and keyboard "enter" are emulated. key.enter is a part of the code, because the arduino software requires it to send data.

*note look over golepie's syntax.  It is VERY easy to code in but its a bit different from wiring.

GLOVEPIE

Code: [Select]
key.a + key.enter = wiimote.a
key.b + key.enter = wiimote.b


arduino code

Code: [Select]
// wiimote led on off control

#define led 13

char cin(){
  while(true){
    if(Serial.available() > 0){
      return Serial.read();
}}}

void setup(){
Serial.begin(115200);  //this is the baud I typically use
pinMode(led,OUTPUT);
}

void loop(){
char command = cin();

     if(command == 'a') digitalWrite(led,HIGH);
else if(command == 'b') digitalWrite(led,LOW);
}



Title: Re: Arduino PS2 Controller
Post by: madsci1016 on June 25, 2010, 04:38:20 PM
For those who find this thread through Google, I have created a fully functional PS2 Controller Arduino library.

http://www.billporter.info/?p=240 (http://www.billporter.info/?p=240)

Enjoy.