Reference for Wiring version 0027+ If you have a previous version, use the reference includede with your software. If see any errors or have any comments, let us know.

Class

Serial

Name

peek()

Examples
int val;

void setup() {
  Serial.begin(9600);
}

void loop() {
  if( Serial.available() > 0) {
    val = Serial.peek();
    Serial.print("Next byte available is: ");
    Serial.println(val);
  }  
}
Description Returns the value of the next byte available without doing a reading.
Syntax
serial.peek()
Parameters
serial The hardware serial port, it can be Serial or Serial1
Returns int: The value for the next byte of data available or -1 if no data is available.
Usage Application
Updated on February 22, 2011 06:16:21pm PST

Creative Commons License