Used for communication between the Maple board and a computer or other devices.
The Maple has three serial ports (also known as a UARTs or USARTs): Serial1, Serial2, and Serial3. They communicate using the pins summarized in the following table:
Serial port | TX, RX, CK | CTS, RTS (if present) |
---|---|---|
Serial1 | 7, 8, 6 | |
Serial2 | 1, 0, 10 | 2, 3 |
Serial3 | 29, 30, 31 | 32, 33 |
Thus, if you use a particular serial port, you cannot also use its communication pins for other purposes at the same time.
If you want to communicate with the Maple using the provided USB port, use SerialUSB instead.
To use them to communicate with an external TTL serial device, connect the TX pin to your device’s RX pin, the RX to your device’s TX pin, and the ground of your Maple to your device’s ground.
Warning
Don’t connect these pins directly to an RS232 serial port; they operate at +/- 12V and can damage your board.
All of the Serial[1,2,3] objects are instances of the HardwareSerial class, which is documented in this section. (This means that you can use any of these functions on any of Serial1, Serial2, and Serial3).
Serial port class. Predefined instances are Serial1, Serial2, and Serial3.
Set up a HardwareSerial object for communications. This method must be called before attempting to use the HardwareSerial object (typically, you call this in your setup() function).
Disables the USART associated with this object, allowing any associated communication pins to be used for other purposes.
Returns the number of bytes available for reading.
Returns the next available, unread character. If there are no available characters (you can check this with available), the call will block until one becomes available.
Removes the contents of the Serial’s associated USART RX FIFO. That is, clears any buffered characters, so that the next character read is guaranteed to be new.
Print the given byte over the USART.
Print the given character over the USART. 7-bit clean characters are typically interpreted as ASCII text.
Print the given null-terminated string over the USART.
Print the argument’s digits over the USART, in decimal format. Negative values will be prefixed with a '-' character.
Print the argument’s digits over the USART, in decimal format.
Print the argument’s digits over the USART, in decimal format. Negative values will be prefixed with a '-' character.
Print the argument’s digits over the USART, in decimal format.
Print the digits of n over the USART, in base base (which may be between 2 and 16). The base value 2 corresponds to binary, 8 to octal, 10 to decimal, and 16 to hexadecimal. Negative values will be prefixed with a '-' character.
Like print(c), followed by "\r\n".
Like print(b), followed by "\r\n".
Like print(n), followed by "\r\n".
Like print(n), followed by "\r\n".
Prints "\r\n" over the USART.
Sends one character over the USART. This function is currently blocking, although nonblocking writes are a planned future extension.
This is a low-level function. One of the print() or println() functions is likely to be more useful when printing multiple characters, when formatting numbers for printing, etc.
Send the given null-terminated character string over the USART.
This is a low-level function. One of the print() or println() functions is likely to be more useful when printing multiple characters, when formatting numbers for printing, etc.
Writes the first size bytes of buf over the USART. Each byte is transmitted as an individual character.
This is a low-level function. One of the print() or println() functions is likely to be more useful when printing multiple characters, when formatting numbers for printing, etc.
Unlike the Arduino, none of the Maple’s serial ports is connected to the USB port on the Maple board (for that, use SerialUSB). Thus, to use these pins to communicate with your personal computer, you will need an additional USB-to-serial adaptor.
License and Attribution
This documentation page was adapted from the Arduino Reference Documentation, which is released under a Creative Commons Attribution-ShareAlike 3.0 License.