Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Ps3 Controller on: October 09, 2012, 10:38:13 am
Can we use "Ps2 dualshock" library on wireless "Ps3 dualshock" controller....??? smiley-sad
2  Using Arduino / Programming Questions / Re: Flushing Arduino on: October 05, 2012, 01:06:38 pm
Code:
type=1;
  error=0;
I included this part so that code should run...before .. code wasn't working..I dont think there is error in this part.. smiley-slim
3  Using Arduino / Programming Questions / Re: Flushing Arduino on: October 05, 2012, 12:30:54 pm
I even assumed the same n overwrited a program over it.
i am tryin to connect a PS2 wireless remote using arduino so without pressing any button i am already getting the
outputs along with the ones which i pressed.

here is my code:
#include <PS2X_lib.h>
#include <Servo.h>


PS2X ps2x;
Servo myservo;

int error=0;
int type=0;
byte vibrate=0;

int pos=90;
const byte servoPin=9;
byte incomingByte;


void setup()
{
Serial.begin(57600);
myservo.attach(9);
pinMode(servoPin,OUTPUT);

error=ps2x.config_gamepad(10,12,11,13,true,false);   //[clock,command,attention,data,pressure,rumble]

if(error==0)
{
Serial.println("PS2 CONTROLLER FOUND, CONFIGURED SUCCESSFUL");
Serial.println("TRY ALL BUTTONS,X WILL VIBRATE THE CONTROLLER");
Serial.println("not for now:HOLDING  L1 OR R1 WILL PRINT OUT THE ANALOG STICK VALUES");
Serial.println("LETS GET IT ON!!!!!");
}
else if(error==1)
Serial.println("NO CONTROLLER FOUND ,CHECK WIRING");
else if(error==2)
Serial.println("CONTROLLER FOUND BUT NOT ACCEPTING COMMANDS");
else if(error==3)
Serial.println("CONTROLLER REFUSING TO ENTER PRESSURE MODE,MAY NOT SUPPORT IT");

type=ps2x.readType();
switch(type)
{
case 0: Serial.println("UNKNOWN CONTROLLER TYPE");
break;
case 1: Serial.println("DUALSHOCK CONTROLLER FOUND");
break;
case 2: Serial.println("GUITAR HERO CONTROLLER FOUND");
break;
}
}


void loop()
{
  
  type=1;
  error=0;
if((error==1)||(error==2)||(error==3))
{
return;
}
else if(error==0)
{
if(type==1)
{
ps2x.read_gamepad();

if(ps2x.Button(PSB_GREEN))
{
Serial.println("YOU PRESSED TRIANGLE");
pos=0;
myservo.write(pos);
}
if(ps2x.Button(PSB_RED))
{
Serial.println("YOU PRESSED CIRCLE");
pos=135;
myservo.write(pos);
}
if(ps2x.Button(PSB_PINK))
{
Serial.println("YOU PRESSED SQUARE");
pos=45;
myservo.write(pos);
}

}

}
delay(20);
}
4  Using Arduino / Programming Questions / Re: Flushing Arduino on: October 05, 2012, 12:14:24 pm
 how to clear previous programme in arduino.....I m programming wireless ps2 controller using arduino ...when I uploaded programme for first time I gave input through ps2 controller and I got some output...but after that I modified my programme  and uploaded it again on ps2 then it started giving previous output along with present one... smiley-sad
5  Using Arduino / Programming Questions / Flushing Arduino on: October 05, 2012, 12:03:01 pm
Plz someone tell me how to flush Arduino...???
6  Using Arduino / Programming Questions / Re: Brushless motor control using arduino on: September 19, 2012, 12:11:17 am
I am giving seperate 9v supply to ESC which drives brushless motor.I did all connention as stated on website.It gives on beep then move at an certian angle and stops..these process repeats.Is there eroor in my logic in code...Here is my code ::

#include "Servo.h"

#define MOTOR_PIN         10
#define MOTOR_MAX_SPEED              180
#define MOTOR_START_SPEED               80

int motor_current_speed = 0;
int motor_increment = 1;
int max_reached = 0;

Servo motor;


void motorSetSpeed(int speed)
{

   if     (speed > MOTOR_MAX_SPEED)
      speed = MOTOR_MAX_SPEED;
   else if(speed < MOTOR_START_SPEED);
      speed = MOTOR_START_SPEED;

   motor.write(speed);
   motor_current_speed = speed;

   Serial.print("current motor speed = ");
   Serial.println(motor_current_speed);
}

void motorSpeedUp()
{


   int increment = (motor_current_speed < 100) ? motor_increment + 2: motor_increment ;
        motorSetSpeed(motor_current_speed + increment);
}

void motorSlowDown()
{
  int increment = (motor_current_speed < 100) ? motor_increment + 2: motor_increment ;
   motorSetSpeed(motor_current_speed - increment);
}

void motorStop()
{
   motor.write(0);
}



void motorStartAt(int start_speed)
{
   int i;
   for (i=0; i < start_speed; i+=5)
       {
      motorSetSpeed(i);
      Serial.println(i);
      delay(10);
   }
}

void setup()
{

   
   Serial.begin(9600);

   
   delay(1000);
   motor.attach(MOTOR_PIN);
   motorStartAt(MOTOR_START_SPEED);
   delay(1500);
}

void loop()
{

        if (!max_reached)
        {
            motorSpeedUp();
        } else
        {
            motorSlowDown();
        }
        if (motor_current_speed < MOTOR_START_SPEED)
        {
            max_reached = 0;
        } else if (motor_current_speed > MOTOR_MAX_SPEED)
        {
            max_reached = 1;
        }
        delay(50);
}
7  Using Arduino / Programming Questions / Brushless motor control using arduino on: September 18, 2012, 04:32:29 pm
I am having problem in controlling speed of brushless motor using ESC .It move at certian angle then stop for few second then again start moving and stops.I tried   reducing delay time but no success.


8  Using Arduino / Programming Questions / Re: ps2 interfacing with arduino on: September 18, 2012, 04:00:37 pm
ya...... I was talking about sony playstation....I am making hovercraft which consist of one servo motor and two brushless motor. I need to install this system on one platform and need to control this system wirelessly using ps2.I am having problem in understanding  how to control this three motor using ps2. I first tried interfacing servo with ps2....but no success.
 
9  Using Arduino / Programming Questions / ps2 interfacing with arduino on: September 18, 2012, 12:57:43 pm
Hey I am new to arduino programming.I wanted to interface ps2 with arduino to drive my servo and brushless motor.Can anyone please give me some idea about interfacing ps2 smiley-confuse
Pages: [1]