Arduino

Reference Language | Libraries | Comparison | Changes

## SoftwareSerial: listen()

#### Description

Enables the selected software serial port to listen. Only one software serial port can listen at a time; data that arrives for other ports will be discarded. Any data already received is discarded during the call to listen() (unless the given instance is already listening).

#### Syntax

mySerial.listen()

#### Parameters

mySerial:the name of the instance to listen

#### Returns

None

#### Example

#include <SoftwareSerial.h>
// software serial : TX = digital pin 10, RX = digital pin 11
SoftwareSerial portOne(10, 11);
// software serial : TX = digital pin 8, RX = digital pin 9
SoftwareSerial portTwo(8, 9);
void setup()
{
// Start the hardware serial port
Serial.begin(9600);
// Start both software serial ports
portOne.begin(9600);
portTwo.begin(9600);
}
void loop()
{
portOne.listen();
if (portOne.isListening()) {
Serial.println("Port One is listening!");
}else{
Serial.println("Port One is not listening!");
}
if (portTwo.isListening()) {
Serial.println("Port Two is listening!");
}else{
Serial.println("Port Two is not listening!");
}
}
[Get Code]

#### See also

- SoftwareSerial()
- read()
- print()
- println()

Reference Home

Corrections, suggestions, and new documentation should be posted to the Forum.

The text of the Arduino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.

### Share

### This link has expired.
Please re-subscribe to our Newsletters.

### Subscribe to our Newsletters

Email

Please enter a valid email to subscribe

Arduino Newsletter
Arduino Store Newsletter

### Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy

###### Newsletter

- ©2015 Arduino
- Copyright Notice
- Contact us
- Careers