Using mega serial pins for GPIO

Hi,
Are there any restrictions for using the MEGA serial pins (tx1,2,3 and rx1,2,3) as discrete outputs? I’d like to use them to dive one 5v, 15ma bulb each. It didn’t seem to work when I tried just treating them as other DO pins.

Same question also for SDA and SDC - can they be used as DOs if I don’t need them for IC2?

Never mind. I just found this:
If you are using Arduino MEGA 2560, you have 4 hardware serial ports (USART port to be precise). Not everyone needs to use all of them. You can, if you want, use Serial1,2,3 as regular digital pins, or GPIO (general purpose input and output). All you have to do is to call Serial1.end() before you set RX1 and TX1 with pinMode and digitalWrite/read. Will try.

Check the Arduino Pin Mapping for the Mega! All pins can have multiple functions and may be wired to multiple connectors. E.g. RX1 and TX1 share the same pins with D18 and D19.

Hi,
Welcome to the forum.

What is the application that you are using all the many 2560's I/O?

Thanks.. Tom.. :slight_smile:

My project is a bit hard to explain. It’s a mechanical art project and I’m using the Mega to drive a large collection of motors, lights, and assorted other things. I’m using 595s to drive some of these but didn’t want the serial lines to go to waste if they could be used. I would have thought that I wouldn’t need to call the serial.end function for the serial channels to work as GPIO if I hadn’t already called the begin function for these channels, but the note I pasted above suggests that should work. I’ll try it today to be sure and report back if I’m still having problems.

Did a quick test with just one of the serial pins and worked even without the call to serial.end. Huh. Perhaps I just did something wrong last time.

Just be careful with the total output current. The sum of all output pins cannot exceed 200ma.