Serial.read()
From Microduino Wiki
Read the serial port data, and read() inherits the utility classes from Stream.
- Syntax:
Serial.read()
microduino core only:
Serial.read()
Serial1.read()
- Parameters:
No
- Returned valuse:
The first byte can be read on the serial ports is of (if there is no data can be read, return -1)- int type.
- Example:
int incomingByte = 0; // used to store the data read from serial ports void setup() { Serial.begin(9600); // open the serial port, and set the speed as 9600 bps } void loop() { // send data only when receiving data if (Serial.available() > 0) { // read the incoming bytes incomingByte = Serial.read(); // indicate the data you receive Serial.print("I received: "); Serial.println(incomingByte, DEC); } }