Page 1 of 1

Interfacing FD04A and SKPS with Arduino (Cytron tutorial)

PostPosted: Sat Mar 23, 2013 1:36 pm
by Jonathan Law
I have Arduino Duemilanove , SKPS and PS2 wireless controller with me now,
I followed the steps as shown in tutorial,
i test the SKPS connection with arduino by lights up led if button up pressed, as shown in below coding
CODE: SELECT_ALL_CODE
//skps protocol
#define p_Up       4
#define p_Right       5
#define p_Down       6
#define p_Left       7
#define   p_L2       8
#define   p_R2       9
#define p_L1       10
#define p_R1       11
#define p_Triangle  12
#define p_Circle    13
#define p_Cross       14
#define   p_Square    15

const int rx = 0;
const int tx= 1;

void setup()
{
  Serial.begin(9600);      //Set serial baud rate as 9600
  Serial.flush();          //Waits for the transmission of outgoing serial data to complete.
 
  //Set the mode for each digital pins whether input or output
  pinMode(rx, INPUT);
  pinMode(tx, OUTPUT);
 
  pinMode(3,OUTPUT);
}

void loop ()
{
   if(skps(p_Up)==0)            //Check whether Up button is pressed
  {
    digitalWrite(3,HIGH);                  //Call move_up function, it will move forward
  }
 
  else if(skps(p_Down)==0)   //Check whether Down button is pressed      
  {   
    digitalWrite(3,LOW);      //Call move_down function, it will move backward         
  }
}

unsigned char receive_data(void)  //Function to wait for a byte receive from UART
{
  unsigned char temp;
  while(!Serial.available());    //Wait until data received
  temp=Serial.read();
  return temp;                    //Return the received data
}

unsigned char skps(unsigned char data)   //Function to send out a byte via UART
{                              
  Serial.write(data);             //Send new data
  return receive_data();          //Return received data
}
 


when PS2 controller button pressed, STATUS led in SKPS blinking shows signal received, but the led didt lights up.
I'm using arduino IDE 1.0.1
Did i missed anything? appreciate if anyone can help

Re: Interfacing FD04A and SKPS with Arduino (Cytron tutorial

PostPosted: Tue Mar 26, 2013 9:11 am
by gadgetng
The code seems like don't have any problem and should be working. Anyway just a reminder
1. Hardware connection is correct - RX to TX and vice versa
2. Did you add in the extra LED to pin 3? Is the wiring correct? Why not use pin 13 which is already a LED on the board (Label L).

Re: Interfacing FD04A and SKPS with Arduino (Cytron tutorial

PostPosted: Tue Mar 26, 2013 9:26 am
by robosang
Well, as I always stress.... picture of hardware please.

Re: Interfacing FD04A and SKPS with Arduino (Cytron tutorial

PostPosted: Tue Mar 26, 2013 9:15 pm
by Jonathan Law
I modified the code again, i'm using pin 13 led from arduino board,I test the pin13 LED, it works fine for blinking with delay.
For my code,when triangle button on PS2 pressed, pin 13 led (marked L) should light up.
But still didt works, when i pressed the triangle button, SKPS status LED give 100% brightness,but LED pin 13 didt lights up.
i think SKPS works well to receive data from PS2 wireless controller but i have no idea whats going wrong.
CODE: SELECT_ALL_CODE
//skps protocol
#define p_Up       4
#define p_Right       5
#define p_Down       6
#define p_Left       7
#define   p_L2       8
#define   p_R2       9
#define p_L1       10
#define p_R1       11
#define p_Triangle  12
#define p_Circle    13
#define p_Cross       14
#define   p_Square    15



void setup()
{
  Serial.begin(9600);      //Set serial baud rate as 9600
  Serial.flush();          //Waits for the transmission of outgoing serial data to complete.
 
  //Set the mode for each digital pins whether input or output
  pinMode(0, INPUT);
  pinMode(1, OUTPUT);
 
  pinMode(13,OUTPUT);
}

void loop ()
{
   if(skps(p_Triangle)==0)            //Check whether Up button is pressed
  {
    digitalWrite(13,HIGH);                  //Call move_up function, it will move forward
  }
 
}

unsigned char receive_data(void)  //Function to wait for a byte receive from UART
{
  unsigned char temp;
  while(!Serial.available());    //Wait until data received
  temp=Serial.read();
  return temp;                    //Return the received data
}

unsigned char skps(unsigned char data)   //Function to send out a byte via UART
{                              
  Serial.write(data);             //Send new data
  return receive_data();          //Return received data
}
 


i uploaded the picture regarding my hardware connection for your reference.
Thanks

Re: Interfacing FD04A and SKPS with Arduino (Cytron tutorial

PostPosted: Wed Mar 27, 2013 11:49 am
by robosang
Have you successfully load the sketch into the Arduino? Because when you connect UART pins on Arduino, normally the bootloader will be disturbed and the uploading will fail.

Another thing, try press the reset button on Arduino after the connection is ready, then only press the button on PS2 :mrgreen:

Re: Interfacing FD04A and SKPS with Arduino (Cytron tutorial

PostPosted: Wed Mar 27, 2013 12:05 pm
by shahrul
robosang WROTE:Have you successfully load the sketch into the Arduino? Because when you connect UART pins on Arduino, normally the bootloader will be disturbed and the uploading will fail.

That's right. Arduino uploading use TX and RX (pin 0 and pin 1). So, need to remove any device at that pin while downloading, if not it fail downloading.

Re: Interfacing FD04A and SKPS with Arduino (Cytron tutorial

PostPosted: Thu Mar 28, 2013 12:15 pm
by gadgetng
I just tested the coding in your first post and it is working. Anyway, i only got the wired PS2 with me. So it is either the wiring connection or the wireless PS2 is not compatible with SKPS?

Re: Interfacing FD04A and SKPS with Arduino (Cytron tutorial

PostPosted: Fri Mar 29, 2013 8:16 pm
by Jonathan Law
gadgetng WROTE:I just tested the coding in your first post and it is working. Anyway, i only got the wired PS2 with me. So it is either the wiring connection or the wireless PS2 is not compatible with SKPS?


can you post your successful hardware connection pictures here pls..just for my reference
thanks