Software serial on any pins? - SOLVED

hello i was wondering sense I never done software serial Can I use them on any pin? I see different sites state to use D9 and D10 for them. but I was curious If I can use D4 and D5 that is the only pins I have available.

Joseph

What model Arduino are you using?

Some pin limitations are listed here.
https://www.arduino.cc/en/Reference/softwareSerial

Hello cattledoy, I'm using the SamD21 Arduino zero chip. I'm just right now breadboarding it. I'm going to be using all the pins besides the D4 and D5.

Joseph

This page may be of interest. (found with a search for "SamD21 Arduino zero serial ports")

Thank you, I'm looking at it now.

Joseph

Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. These pins are connected to the Serial1 class. The native usb port instead responds to the SerialUSB class.

I'm not clear on which pins from the chip these Tx and Rx pins connect to, but if you are using the Arduino core to work with the chip, then Serial1 will be the most simple choice.

Given this second hardware serial port, its not clear that software serial is supported on that platform.

Hello I can not using the native pins. They are used for other things. I'm using the SWD pins to program the D21 chip. However The SWD doesn't do Serial monitoring like If I was doing Jtaging. Only pins I have Available and not being used is D4 and D5.

Joseph

I'm not sure what the 4/02 and 4/03 means? When I see D4 and D5. It looks like it is under Perip.D.

Joseph

Hello vI'm wrong. It looks like I'm not using D4 and D5. The pins that are free are IO0 and IO1. Which looks like D0 and D1.

I was having a hard time trying to get the pins to do something. Like a Blink Led and that wasn't working. I totally forgot which pins was free and available. I had to take my multiple meter and figure it out. Now I do have the correct pins IO0 and IO1. That would be D0 and D1.

Joseph

What else is taking up all your other pins? Maybe you can free up some of them with a shift register or an I2C interface module?

a 3.5" lcd that takes up almost 3/4 pins then I have the 1/2 with sensors on it.

Joseph

So you are using an lcd module with a parallel interface, correct? In that case, you can handle the 8 data pins with a shift register. However... 3/4 of the pins is something like 15 or 16 pins, all for an lcd: that's a lot! What kind of device is that? Do you have a link?

3.5" lcd It has touch and Sd card.

Joseph

I don't think that the SAMD21 boards support SoftwareSerial at all (not on ANY pins.)

If D0/D1 are the pins you have free, they support HardwareSerial as "Serial1"

The datasheet for your module states that the module supports SPI in addition to parallel interface, but it warns that the former may be slower. You can use a shift register between the arduino and the parallel line, but this will also be a bit slower than straight parallel. You can also daisy-chain a couple of shift registers, and free up even more pins, but the display will be slower still. You may not notice the slowdown, but you might: you'll have to experiment with the application you have in mind.

However: take a look at your library, if you are using one, and check if you are using the Arduino.h functions like digitalWrite() and friends. If you are, dumping them in favour of direct port manipulation may give you back some of the speed that you lose by using serial instead of parallel.

Another solution, of course, is to switch uCs and reach for a Mega instead of an Uno.

I'm using a SamD21 processor Which is the Arduino zero bootloader. About 10 times more processing speed then a mega. My speed is not my problem.

My problem is I need to do a Serial monitor and The pins I thought I have Are D4 and D5 which are the only pins I can use for that. But it looks like I'm The pins are IO0 and IO0 it looks like they are the Hardware Serial pins and Westfw Did confirm that they are. So I might be okay.

I'm using a SWD programmer and it doesn't have serial monitoring. If I did Jtaging programming thern I would have serial monitoing. Problem is I do not know how to Jtag only swd programming.

Joseph

My bad, I overlooked that part. Since speed is not a problem in your case, using shift registers will free up all the pins that you want.

[Edit] fixed typo.

back of the screen haves two shift registers or line level drivers on it. I'm not sure I need to look at it closely. But I will need to do something to free up some pins.

Joseph

Hi @josephchrzempiec

A while ago, Arduino.org did produce a Software Serial library for their SAMD21 based M0 Pro/M0 board, however that disappeared together with their Github repository, when they merged back with Arduino.cc.

The reason why the SAMD21 boards don't have Software Serial support, is because it's possible to configure the microcontroller's unused and spare SERCOM (Serial Communication) modules, to be either an additional hardware: Serial, SPI or I2C ports.

Adafruit have an excellent tutorial, located here: https://learn.adafruit.com/using-atsamd21-sercom-to-add-more-spi-i2c-serial-ports/overview.

+1 for that. There's no reason to mess around with Software Serial when you can instantiate more hardware UART ports.