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

begin()

Examples
int val;

void setup() {
  Serial.begin(9600);  // Start serial Serial at 9600 baud
}

void loop() {
  if ( Serial.available() > 0 )  // if data is available to read
  {
    val = Serial.read();        // read it and store it in 'val'
  }
  analogWrite(0, val);
}

int val;

void setup() {
  Serial1.begin(115200);  // Start serial Serial1 at 115200 baud
}

void loop() {
  if ( Serial1.available() > 0 )  // if data is available to read
  {
    val = Serial1.read();  // read it and store it in 'val'
  }
  analogWrite(0, val);
}
Description The Wiring serial library allows for easily reading and writing data to external machines. The serial port used to be a nine pin I/O port that existed on most PCs and can be emulated through a USB serial adapter. The begin(rate) method must be placed in the setup() method.
Syntax
serial.begin(rate)
Parameters
rate Integer specifying the speed: 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600 or 115200 bauds
serial The hardware serial port, it can be Serial, Serial1 or if available Serial 2, Serial3.
Returns None
Usage Application
Updated on July 07, 2011 11:08:53pm PDT

Creative Commons License