SoftwareSerial usage

Hi,

I am using the TFMPlus library to setup an obstacle sensor using TF Luna LiDAR sensor. I am using the example program to begin with.

The code sets up the serial port as shown below:
#include <SoftwareSerial.h>
SoftwareSerial mySerial( 10, 11);

It works only with those pins (10,11) and does not work with any other combination of PWM digital pins (such as 7 & 8 or 6 & 7). And, I am using Arduino mega. For some reason I have to use SoftwareSerial for this sensor, though there are 3 HardwareSerial ports...

Am I missing anything? Any help is highly appreciated...

-Manjuanth

Your topic has been moved; do not post in "Uncategorized". Please read the sticky topics in Uncategorized - Arduino Forum.

Please post your code using code tags (as described in How to get the best out of this forum).

Mega have 4 UARTs, 3 of them are free to use.
why you think SerialSoftware needs only PWM pins?

What does "does not work" mean?

The TFMP_example.ino uses serial port 2 of the mega.
Connect the LIDAR to pins 17(RX2), 16(TX2) and use the example code

RX<-TX
TX->RX

The reason I am forced to use a SoftwareSerial is because I have four (or even five if I can) sensors that I need to use...

-Manjunath

Ya, but you can uncomment the lines to use SoftwareSerial ports..

but it won't work with software serial, so leave them Commented

I get zero reading when use other PWM pins.. It works only with pins 10, 11..

See the reference: https://docs.arduino.cc/learn/built-in-libraries/software-serial/

3 Likes

Sure..thanks.. I am a newbie..

thanks..I will look up the reference..