serialEvent()
Description
This function is automatically called when data is available. Use Serial.read(), Serial.readBytes(), Serial.readBytesUntil(), Serial.readString(), or Serial.readStringUntil() to capture this data.
serialEvent() functionality is not available on all Arduino boards or Serial interfaces:
Board | Available serialEvent() functions | |
---|---|---|
Uno Nano | serialEvent() | |
Mega | serialEvent() serialEvent1() serialEvent2() serialEvent3() | |
Leonardo Micro Yún | serialEvent1() | |
Uno WiFi Rev2 Nano Every | None | |
MKR boards Nano 33 IoT Zero | None | |
Nano 33 BLE | None | |
Portenta H7 | None | |
Due | serialEvent() serialEvent1() serialEvent2() serialEvent3() | |
101 | serialEvent1() |
Syntax
For boards with additional serial ports (see the list of available serial ports for each board on the Serial main page):
Parameter Values
- statements: any valid statements
Return Values
- Nothing
Example Code
- Compile and upload the above code to Arduino
- Type "Arduino" on Serial Monitor and click Send button:
- The result on Serial Monitor:
※ NOTES AND WARNINGS:
Serial functions are not only used for the communication between an Arduino board and Serial Monitor of Arduino IDE but also used for the communication between:
- An Arduino board and other Arduino board
- An Arduino board and other sensors/devices
- An Arduino board and computer (any Serial software on computer)* An Arduino board and other Arduino board
- An Arduino board and other sensors/devices
- An Arduino board and computer (any Serial software on computer)
See Also
- Language : Arduino - Serial
- Language : Serial.available()
- Language : Serial.availableForWrite()
- Language : Serial.begin()
- Language : Serial.end()
- Language : Serial.find()
- Language : Serial.findUntil()
- Language : Serial.flush()
- Language : Serial.getTimeout()
- Language : if(Serial)
- Language : Serial.parseFloat()
- Language : Serial.parseInt()
- Language : Serial.peek()
- Language : Serial.print()
- Language : Serial.println()
- Language : Serial.read()
- Language : Serial.readBytes()
- Language : Serial.readBytesUntil()
- Language : Serial.readString()
- Language : Serial.readStringUntil()
- Language : Serial.setTimeout()
- Language : Serial.write()
※ ARDUINO BUY RECOMMENDATION
Arduino UNO R3 | |
Arduino Starter Kit |