Pages: [1]   Go Down
Author Topic: Arduino Mega 2560 UART with other device  (Read 820 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm new to arduino and having Arduino Mega 2560 with me,
I wish to connect Arduino with below device using UART.
User manual can be found in above website,
Seems complicated because there are three RX and TX pin available in Arduino Mega 2560,
Anyone here can help me in establish UART coding?

I found some useful code but not works for my project

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);
unsigned char receive_data(void)  //Function to wait for a byte receive from UART
  unsigned char temp;
  while(!Serial.available());    //Wait until data received;
  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
« Last Edit: March 05, 2013, 11:15:27 am by JonathanLaw » Logged

Offline Offline
Shannon Member
Karma: 223
Posts: 12630
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The global object Serial represents the hardware UART that is connected to USB.

On Arduinos with additional UARTs, additional objects Serial1 etc are declared to access them. I will leave it to you to work out which object corresponds to which physical connector on your board.

I only provide help via the forum - please do not contact me for private consultancy.

Pages: [1]   Go Up
Jump to: