Two serial devices with one Atmega2560???

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
KingVanilla
 
Posts: 42
Joined: Sun Jun 21, 2015 9:53 pm

Two serial devices with one Atmega2560???

Post by KingVanilla »

Hello everyone and a happy Thanksgiving holiday!

I have a quick (I hope) question about two serial devices I want to communicate with in a custom Atmega2560 board I am designing. I want to talk to an Xbee via serial as well as a SyRen motor controller via serial too. I know that I can control it with a PWM signal, but I would prefer using serial communications because of the more advanced features you can utilize. Could you use two transistors to switch between the data lines of the Xbee and motor controller? Any ideas would be appreciated!

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Two serial devices with one Atmega2560???

Post by adafruit_support_mike »

You could use a multiplexer, but the ATmega2560 has four hardware UARTs, so you could have a dedicated Serial connection for each device.

User avatar
KingVanilla
 
Posts: 42
Joined: Sun Jun 21, 2015 9:53 pm

Re: Two serial devices with one Atmega2560???

Post by KingVanilla »

Okay, so does that mean I would have the Xbee connected to Tx0 and Rx0 and the motor controller attached to Tx1 and Rx1? How would I address them separately in my code though?

User avatar
adafruit_support_bill
 
Posts: 88092
Joined: Sat Feb 07, 2009 10:11 am

Re: Two serial devices with one Atmega2560???

Post by adafruit_support_bill »

The additional hardware serial ports on the Mega are addressed as Serial1, Serial2 and Serial3: https://www.arduino.cc/en/Reference/Serial

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”