Framework (A-Z)

Reference for Wiring version 1.0 Build 0100+ If you have a previous version, use the reference included 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, Serial1 or if available Serial 2, Serial3.
Returns int: The value for the next byte of data available or -1 if no data is available.
Usage Application
Updated on July 07, 2011 11:08:54pm PDT

Creative Commons License