I'm planning a project that will involve multiple serial ports and the Arduino servo library. I have heard that this may cause interrupt conflicts. Are there any simple solutions to this
I have heard that this may cause interrupt conflicts.
Indeed. The Arduino can only run one interrupt routine at a time, and:
- Servos use rapidly firing interrupts
- SoftwareSerial both turns off interrupts while sending (for relatively long periods)
- SoftwareSerial uses an interrupt for receiving that runs for an extended period
So really you can't use both together.
- Use hardware PWM to drive the servos (There is a library for this somewhere)
- Use an external servo PWM driving board (Adafruit do one IIRC)
- Don't use SoftwareSerial. IIRC AltSoftSerial is better, though no software serial implementation will ever be particularly good.
The underlying problem is that the low-end Arduinos only have on serial port. If you need to use more than one serial port then you really need to be looking at using a different Arduino - one with multiple serial ports.