Arduino Mega 2560 UART with SKPS

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

Arduino Mega 2560 UART with SKPS

Postby Jonathan Law » Sun Mar 03, 2013 9:21 pm

I'm using Arduino Mega 2560, going to connect with SKPS using UART.
there are TX0,RX0,TX1,RX1,TX2,RX2,TX3,RX3
how will be the UART coding if i want to use TX0 and RX0 to connect with SKPS?
I found this in cytron tutorial but i'm not sure whether suit to my project or not.

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

Re: Arduino Mega 2560 UART with SKPS

Postby yonghui » Tue Mar 05, 2013 1:04 pm

i think u just try and u will know whther it can be used or not.
thanks&regards,
yh
yonghui
Moderator
 
Posts: 732
Joined: Mon Sep 28, 2009 3:27 pm

Re: Arduino Mega 2560 UART with SKPS

Postby Jonathan Law » Tue Mar 05, 2013 11:59 pm

I connected PS2 wireless controller with SKPS and would like to establish communication between arduino mega 2560 with SKPS and PS2. Above code cnt working to establish this communication,anyone can help me in UART code??
Thanks
Jonathan Law
Novice
 
Posts: 16
Joined: Tue Feb 26, 2013 10:21 am

Re: Arduino Mega 2560 UART with SKPS

Postby robosang » Wed Mar 06, 2013 7:54 am

How is the connection? How do you know it is not working?
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: Arduino Mega 2560 UART with SKPS

Postby Jonathan Law » Fri Mar 22, 2013 10:52 pm

I still having problem to work out with Arduino Mega 2560 with SKPS,
I had connect SKPS with 5V and GND from arduino board, SKPS TX pin and RX pin cross connect with Arduino Mega TX3 and RX3 pin
The connection I refer to http://tutorial.cytron.com.my/2012/07/16/interfacing-fd04a-and-skps-with-arduino/
SKPS STATUS led blinking while i press the PS2 controller, this mean SKPS received signal from PS2 controller but didt give me simple lights up led output. please refer my simple testing code below:
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= 15;
const int tx= 14;

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(53,OUTPUT);
}

void loop ()
{
   if(skps(p_Up)==0)            //Check whether Up button is pressed
  {
    digitalWrite(53,HIGH);               
  }
 
  else if(skps(p_Down)==0)   //Check whether Down button is pressed      
  {   
    digitalWrite(53,LOW);               
  }
}

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

Re: Arduino Mega 2560 UART with SKPS

Postby robosang » Mon Mar 25, 2013 8:44 pm

I thought pin 14 and 15 is serial3 on Arduino Mega... did you study the page from Arduino.cc?
http://arduino.cc/en/Reference/serial
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: Arduino Mega 2560 UART with SKPS

Postby shahrul » Mon Mar 25, 2013 9:14 pm

Jonathan Law WROTE:I still having problem to work out with Arduino Mega 2560 with SKPS,
I had connect SKPS with 5V and GND from arduino board, SKPS TX pin and RX pin cross connect with Arduino Mega TX3 and RX3 pin

Connection to TX3 and RX3, should use Serial3
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor


Return to Arduino Based

Who is online

Users browsing this forum: No registered users and 16 guests