Can I use the TX/RX on pins 0, 1 (to a serial slave device) while also having the USB port dedicated PC communication?
Asked
Active
Viewed 7,208 times
4
-
actually When you uploading a sketch to your board through USB programing port that time the skect might go to the serial device which is connected with Arduino through Rx and Tx pin – Prayuktibid Apr 07 '17 at 04:40
-
1@Prayuktibid I couldn't see any signal on pins 0 or 1 with a scope when using the USB port, even with those pins set to an output. – 101 Apr 07 '17 at 04:47
-
3@Prayuktibid he is using a Leonardo which has separate USB and hardware serial. – gre_gor Apr 07 '17 at 13:06
-
How to use USB and TX/RX at the same time? – Aye Chan Myat Phyoe Oct 01 '18 at 14:44
1 Answers
4
32u4 is multi-serial uC. USB connection works on default serial communication which can be used via Serial.print("somevalue"). On the other hand if you want to use RX/TX on pins 0, 1 which are actually RXD1 and TXD1. So, if you use Serial1.print("somevalue"). So the answer is a yes. You can use USB and RX/TX (hardware serial) at the same time.
Sener
- 394
- 2
- 12
-
Great, thanks. Do you know how this compares with other boards? [Apparently](http://arduino.stackexchange.com/questions/18450/may-i-use-both-usb-serial-and-tx-rx-pins-at-the-same-time) the Uno can't do use both. – 101 Apr 07 '17 at 08:50
-
2Arduino Uno can't do this, it has only one hardware serial. Atmega 2560 has 4 hardware serials. Having multiple serials are always handy. With Uno you just stuck and have to use software serial if the case more than one serial. Most of the time Software Serial doesn't treat you well, it is just a workaround after all. – Sener Apr 07 '17 at 11:08