Southern R2 Builders Group Forum Index Southern R2 Builders Group
A Place for Star Wars Fans
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   Join! (free) Join! (free)  
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PS2 Controller
Page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9  Next
 
Post new topic   Reply to topic    Southern R2 Builders Group Forum Index -> Electronics
View previous topic :: View next topic  
Author Message
Please Register and Login to this forum to stop seeing this advertising.






Posted:     Post subject:

Back to top
Danf



Joined: 25 Aug 2010
Posts: 80
Location: Brandon, Fl

PostPosted: Sun Aug 14, 2011 11:27 pm    Post subject:  Reply with quote

The library does all the hard work of figuring out all the signals from the ps2 controller. What button is pressed, joystick position, ect.  But you have to tell it what to do when a button is pressed or stick is moved. Its not very difficult to do. Depends on your setup. I setup the drive and dome Using Arduino's included servo library,  and found a library for my sparkfun mp3 trigger. Basically it's   if (ps2.buttonPressed(red))  trigger.play(3);    I'd be happy to share my code with anyone interested in it, it works with a sabertooth dual speed controller for the foot drives, a Senna style dome drive ( a servo bumps switches) and the sparkfun mp3 board.
Back to top
View user's profile Send private message Send e-mail
admin
Site Admin


Joined: 23 Aug 2010
Posts: 330
Location: Jacksonville, Florida

PostPosted: Sun Aug 14, 2011 11:48 pm    Post subject: Reply with quote

I noticed the video shows additional parts attached to the Ps2 controller so it could send the signal to the robot.
Is there a away to eliminate the extra parts attached to the wired Ps2?

Years ago I was working on a setup similar to what your working on and the code would allow for multiple buttons to changed what they controlled.
You could hold a front trigger button on the controller and it would shift what the buttons could control.

I'd love to see your setup work.
Calvin
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Danf



Joined: 25 Aug 2010
Posts: 80
Location: Brandon, Fl

PostPosted: Mon Aug 15, 2011 11:24 pm    Post subject: Reply with quote

Ah, I see what you're talking about. You can just use a wireless controller, just like with the c6c, I don't know why he used all that stuff in the video.  I set up the buttons so if I just press one of the four shape ones, it plays a random sound in 4 categories. If I hold the L1 trigger and press one of the four I get a specific sound, scream, wolf whistle, Leia message, etc. L2 +one of the 4 gives a different set and R1 +one of the 4 plays music. I'll try to remember to bring my camera to work and take a little video. And your right, With a little practice it's much easier to control. I'm loving this setup!
Back to top
View user's profile Send private message Send e-mail
admin
Site Admin


Joined: 23 Aug 2010
Posts: 330
Location: Jacksonville, Florida

PostPosted: Tue Aug 16, 2011 12:31 am    Post subject: Reply with quote

A video would be great!
Will you guys be posting your code?
Or a part list.
Calvin
Back to top
View user's profile Send private message Send e-mail Visit poster's website
admin
Site Admin


Joined: 23 Aug 2010
Posts: 330
Location: Jacksonville, Florida

PostPosted: Wed Aug 17, 2011 1:33 am    Post subject: Reply with quote

Which Arduino are you guys using and where to order it?
Calvin
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Blsith



Joined: 24 Aug 2010
Posts: 191

PostPosted: Wed Aug 17, 2011 11:53 am    Post subject: Reply with quote

I had a chance to stop by and see Dan's R2 in action.  The controller functions look really good!  I definitely liked how it's an "all in 1" solution with quick hit buttons.

Very cool!
_________________
Brian Lube - R4-P17 -  Member of the Southern R2 Builders  -  [URL=http://r4-p17.blogspot.com][/URL]
Back to top
View user's profile Send private message AIM Address
admin
Site Admin


Joined: 23 Aug 2010
Posts: 330
Location: Jacksonville, Florida

PostPosted: Wed Aug 17, 2011 10:50 pm    Post subject: Reply with quote

Do you think this setup could also control Teecee's light system.
It also uses a Arduino.
Calvin
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Danf



Joined: 25 Aug 2010
Posts: 80
Location: Brandon, Fl

PostPosted: Wed Aug 17, 2011 11:45 pm    Post subject: Reply with quote

Here is a video link

http://www.youtube.com/watch?v=H9BcXc7ixT0

As to controlling Teeces logics, that is my next step. I have one Arduino in the dome to run the logics and psi's, and plan to hookup some servos to it to move the hp and open some panels, and one in the body for the Ps2 and Mp3 Trigger.  I have to figure out how to hook them together, I think through a serial connection. (I'm just learning all of this stuff) Unfortunately, it may take me a little while as I have gotten a bit behind at work (playing with all of this). Once I get that figured out, we'll have to come up with a good name for the system, like The Padawan System - Playstation, Arduino, ..Digital,....Analog,...um...Wan. Anyway, here is my code for just the Sabertooth and the dome

Code:
#include <PS2X_lib.h>  //for v1.6
#include <Servo.h>
PS2X ps2x; // create PS2 Controller Class
Servo RXservo;
Servo RYservo;
Servo LXservo;
int error = 0;
byte type = 0;
byte vibrate = 0;

void setup(){

 RXservo.attach(6);
 RYservo.attach(7);
 LXservo.attach(5);
 error = ps2x.config_gamepad(13,11,10,12, true, false);   //setup pins and settings:  GamePad(clock, command, attention, data, Pressures?, Rumble?) check for error
 
 type = ps2x.readType();
 }

void loop(){
    
 if(error == 1) //skip loop if no controller found
  return;
  
  ps2x.read_gamepad();          //read controller
      
   RXservo.write(map(ps2x.Analog(PSS_RX), 0, 255, 60, 120));
  RYservo.write(map(ps2x.Analog(PSS_RY), 0, 255, 60, 120));
  LXservo.write(map(ps2x.Analog(PSS_LX), 0, 255, 60, 120)); ;
 delay(50);
    
}


And here it is with the Mp3 trigger added in
Code:
#include <PS2X_lib.h>  //for v1.6
#include <Servo.h>
#include <MP3Trigger.h>
 MP3Trigger trigger;

PS2X ps2x; // create PS2 Controller Class
Servo RXservo;
Servo RYservo;
Servo LXservo;
int error = 0;
byte type = 0;
byte vibrate = 0;
byte vol = 20;

void setup(){
 trigger.setup();
 RXservo.attach(6);
 RYservo.attach(7);
 LXservo.attach(5);
 error = ps2x.config_gamepad(13,11,10,12, true, false);   //setup pins and settings:  GamePad(clock, command, attention, data, Pressures?, Rumble?) check for error
 trigger.setVolume(vol);
 type = ps2x.readType();
 }

void loop(){
    
 if(error == 1) //skip loop if no controller found
  return;
  
  ps2x.read_gamepad();   //read controller and set large motor to spin at 'vibrate' speed
  
 if(ps2x.Button(PSB_PAD_UP))
 { if (vol>0)
 {vol--;
  trigger.setVolume(vol);}
  }
  if(ps2x.Button(PSB_PAD_DOWN))
  { if (vol<255)
 {vol++;
  trigger.setVolume(vol);}
 }
  if(ps2x.ButtonPressed(PSB_GREEN))//triangle top
   {if(ps2x.Button(PSB_L1))
      (trigger.play(8));
    else if(ps2x.Button(PSB_L2))
      (trigger.play(2));
    else if(ps2x.Button(PSB_R1))
      (trigger.play(9));
     else
      (trigger.play(random(13,17)));}
  if(ps2x.ButtonPressed(PSB_BLUE))//x bottom
   {if(ps2x.Button(PSB_L1))
      (trigger.play(6));
    else if(ps2x.Button(PSB_L2))
      (trigger.play(1));
    else if(ps2x.Button(PSB_R1))
      (trigger.play(11));
     else
      (trigger.play(random(17,25)));}
  if(ps2x.ButtonPressed(PSB_RED))//circle right
   {if(ps2x.Button(PSB_L1))
      (trigger.play(7));
    else if(ps2x.Button(PSB_L2))
      (trigger.play(3));
    else if(ps2x.Button(PSB_R1))
      (trigger.play(10));
     else
      (trigger.play(random(32,52)));}
  if(ps2x.ButtonPressed(PSB_PINK))//square left
   {if(ps2x.Button(PSB_L1))
      (trigger.play(5));
    else if(ps2x.Button(PSB_L2))
      (trigger.play(4));
    else if(ps2x.Button(PSB_R1))
      (trigger.play(12));
     else
      (trigger.play(random(25,32)));}
  RXservo.write(map(ps2x.Analog(PSS_RX), 0, 255, 60, 120));
  RYservo.write(map(ps2x.Analog(PSS_RY), 0, 255, 60, 120));
  LXservo.write(map(ps2x.Analog(PSS_LX), 0, 255, 60, 120));
 delay(50);
}
Back to top
View user's profile Send private message Send e-mail
Danf



Joined: 25 Aug 2010
Posts: 80
Location: Brandon, Fl

PostPosted: Thu Aug 18, 2011 12:08 am    Post subject: Reply with quote

admin wrote:
Which Arduino are you guys using and where to order it?
Calvin

I have a Uno with the bigger replaceable chip that I use for testing and programing like this one. http://www.sparkfun.com/products/9950
Than I build my own for each project since I don't really need the USB and programing stuff in there. Sparkfun sells the chips for 5.50 and the rest of the parts are dirt cheep at places likehttp://www.taydaelectronics.com/servlet/StoreFront If you don't like soldering you could use just about any of the Arduino's or clones out there, just realize that some, like the Pro and the Pro mini need a special cable to program them. of course you would only need one cable to program as many as you want. Hope this helps.
Back to top
View user's profile Send private message Send e-mail
wheels



Joined: 17 Jun 2011
Posts: 29

PostPosted: Thu Aug 18, 2011 1:22 am    Post subject: Reply with quote

I agree with you Brian.
The one controller does it all is what has me so intrigued about this set up.
I am trying to get the PS2 joysticks to control movement with the right joystick and dome rotation with the left joystick. At the same time, I am trying to hook up the 10 pin ThinkGeek shirt via some sort of shift register chip, so as not to use all the available slots on the Arduino, to allow the buttons on the controller to operate all 20 sounds and the volume control.

To Calvin:
When Dan and I were working with this in his shop a couple of weeks ago, we were using the Arduino Uno. Like Dan said, it has a removable chip and what he is doing is leaving mounted in the droid and uses a second one to fiddle with and programs the chip then swaps the chip into the board that is mounted in the droid. Very clever and useful.

Way to go Dan!  Very Happy


_________________
--Randy
Member of the Winning Droid Hunt Teams from D*C '05, '06, '07, '08 and CIV
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Southern R2 Builders Group Forum Index -> Electronics All times are GMT
Page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9  Next
Page 2 of 9

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Card File  Gallery  Forum Archive
Powered by phpBB © 2001, 2002 phpBB Group
BlackAndWhite style created by feather inju
Create your own free forum | Buy a domain to use with your forum