Reference.SoftwareSerialAvailable History

Hide minor edits - Show changes to markup

May 25, 2012, at 03:44 PM by Tom Igoe -
Changed lines 23-25 from:
  1. define rxPin 2
  2. define txPin 3
to:
  1. define rxPin 10
  2. define txPin 11
January 07, 2012, at 06:32 PM by Tom Igoe -
Changed lines 19-20 from:

[@// include the SoftwareSerial library so you can use its functions:

to:
Changed lines 42-43 from:

@]

to:
September 24, 2011, at 12:08 AM by Scott Fitzgerald - page creation
Added lines 1-48:

SoftwareSerial: available()

Description

Get the number of bytes (characters) available for reading from a software serial port. This is data that's already arrived and stored in the serial receive buffer.

Syntax

mySerial.available()

Parameters

none

Returns

the number of bytes available to read

Example

// include the SoftwareSerial library so you can use its functions:
#include <SoftwareSerial.h>

#define rxPin 2
#define txPin 3

// set up a new serial port
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);

void setup()  {
  // define pin modes for tx, rx:
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
}

void loop() {
  if (mySerial.available()>0){
  mySerial.read();
 }
}

See also

Share