Show Posts
Pages: [1]
1  Using Arduino / Motors, Mechanics, and Power / Re: ps2 controlled project on: December 11, 2012, 08:54:07 pm
The range i was looking is about a 1.5 miles. I was thinking of using the 900Mhz Xbee's, best bang for the buck, that i could find. I was about to buy a book on programming but i actually just got laid off work today, without any kind of notice. So i'm basically in panic mode now, I'm a auto technician. But I'm not giving up yet!!!
2  Using Arduino / Motors, Mechanics, and Power / Re: ps2 controlled project on: December 10, 2012, 06:54:13 pm
Ok last night i found this code, and uploaded it to the arduino. Pins 11 and 9 are motor outputs, it works ok, still having problems with the joysticks. When i press R1,L1 on the controller this allows me too use the joysticks to control the speed of the motors, the problem is that i have to hold the joy sticks all the way down or the motors will spin about half speed. I have tried to fix this in the code but have not had any luck. here is the code!

#include <PS2X_lib.h>

PS2X ps2x;

//int Lp = 7;
//int Ln = 4;
//int Rp = 8;
//int Rn = 12;
int El = 11;
int Er = 9;
int right_speed = 0;
int left_speed = 0;

void setup () {
  ps2x.config_gamepad(2,6,4,7, true, true);
  //pinMode (Lp, OUTPUT);
  //pinMode (Ln, OUTPUT);
  //pinMode (Rp, OUTPUT);
  //pinMode (Rn, OUTPUT);
  pinMode (El, OUTPUT);
  pinMode (Er, OUTPUT);
 
  digitalWrite (El,LOW);
  digitalWrite (Er,LOW);
  Serial.begin(9600);
}

void loop () {
  ps2x.read_gamepad();
  left_speed = ps2x.Analog(PSS_LY);
  right_speed = ps2x.Analog(PSS_RY);
  left_speed = 255 - left_speed;
  right_speed = 255 - right_speed;
  left_speed = map(left_speed, 127, 255, -255, 255);
  right_speed = map(right_speed, 127, 255, -255, 255);
  if((left_speed>=-25) && (left_speed<=45)) {
     left_speed = 0;
  }
  //WHAT SHOULD I PUT IN THE ELSE STATEMENT??
  Serial.print("Left Joystick Value: ");
  Serial.print(left_speed);
  Serial.print("\t");
  Serial.print("Right Joystick Value: ");
  Serial.println(right_speed);
 
  if(ps2x.Button(PSB_L1) && ps2x.Button(PSB_R1)) {
    analogWrite(Er, right_speed);
    analogWrite(El, left_speed);
  }
 
  else {
    analogWrite(Er, 0);
    analogWrite(El, 0);
  }
}
3  Using Arduino / Motors, Mechanics, and Power / ps2 controlled project on: December 09, 2012, 08:22:22 pm
Hi, I just found out about the arduino about 2 weeks ago and rushed out and bought one. I have been researching for two weeks about how to use it. What i want to do is control a 4wd home made Rc with a pan and tilt turret on top. I want to use a ps2 controller and use wireless xbees. I have already used the psx2 code, and got the controller working. So im have a problem trying to learn how to get the arduino uno to output to transistors so i can run motors and servos with the joy sticks. I know to makes the circuits for the motors with transistors and what not. Basically i want the left joy stick to drive foward,back,left,and right, and the right joy stick to pan and tilt some servos tied togeather. Ill be using four motors the drive each wheel. I need some help with adding to the psx2 program to make this happen. Any help would be great thanks!
Pages: [1]