Interfacing FD04A and SKPS with Arduino (Cytron tutorial)

Talk about Arduino board, sheilds. Sharing Arduino projects, program, problems, solutions, suggestions..... many more, all are welcome.

Interfacing FD04A and SKPS with Arduino (Cytron tutorial)

Postby Jonathan Law » Sat Mar 23, 2013 1:36 pm

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
Jonathan Law
Novice
 
Posts: 16
Joined: Tue Feb 26, 2013 10:21 am

Re: Interfacing FD04A and SKPS with Arduino (Cytron tutorial

Postby gadgetng » Tue Mar 26, 2013 9:11 am

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).
gadgetng
Discoverer
 
Posts: 97
Joined: Tue Jul 24, 2012 11:20 am

Re: Interfacing FD04A and SKPS with Arduino (Cytron tutorial

Postby robosang » Tue Mar 26, 2013 9:26 am

Well, as I always stress.... picture of hardware please.
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: Interfacing FD04A and SKPS with Arduino (Cytron tutorial

Postby Jonathan Law » Tue Mar 26, 2013 9:15 pm

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
Attachments
DSC06900.JPG
Hardware connection
DSC06901.JPG
After triangle button at PS2 controller pressed
Jonathan Law
Novice
 
Posts: 16
Joined: Tue Feb 26, 2013 10:21 am

Re: Interfacing FD04A and SKPS with Arduino (Cytron tutorial

Postby robosang » Wed Mar 27, 2013 11:49 am

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:
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: Interfacing FD04A and SKPS with Arduino (Cytron tutorial

Postby shahrul » Wed Mar 27, 2013 12:05 pm

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.
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor

Re: Interfacing FD04A and SKPS with Arduino (Cytron tutorial

Postby gadgetng » Thu Mar 28, 2013 12:15 pm

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?
gadgetng
Discoverer
 
Posts: 97
Joined: Tue Jul 24, 2012 11:20 am

Re: Interfacing FD04A and SKPS with Arduino (Cytron tutorial

Postby Jonathan Law » Fri Mar 29, 2013 8:16 pm

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
Jonathan Law
Novice
 
Posts: 16
Joined: Tue Feb 26, 2013 10:21 am


Return to Arduino Based

Who is online

Users browsing this forum: No registered users and 15 guests

cron