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!
Two serial devices with one Atmega2560???
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- KingVanilla
- Posts: 42
- Joined: Sun Jun 21, 2015 9:53 pm
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Two serial devices with one Atmega2560???
You could use a multiplexer, but the ATmega2560 has four hardware UARTs, so you could have a dedicated Serial connection for each device.
- KingVanilla
- Posts: 42
- Joined: Sun Jun 21, 2015 9:53 pm
Re: Two serial devices with one Atmega2560???
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?
- adafruit_support_bill
- Posts: 88092
- Joined: Sat Feb 07, 2009 10:11 am
Re: Two serial devices with one Atmega2560???
The additional hardware serial ports on the Mega are addressed as Serial1, Serial2 and Serial3: https://www.arduino.cc/en/Reference/Serial
Please be positive and constructive with your questions and comments.