Arduino Serial

Serial Communication: Used for communication between the Arduino board and a computer or other devices (also known as a UART or USART ).

Arduino UNO: Rx (Digital Pin 0) and Tx(Digital Pin 1)


Serial

Serial: serial port object.

Return: true if the specified serial port is available.


Serial.begin(speed);

begin: Serial port method.

speed: Argument of begin method, in bits per second (baud). Allowed data types: long.

Return: Nil


while (condition) {

// statement(s)

}

while: A while loop will loop continuously, and infinitely, until the expression inside the parenthesis, () becomes false.

condition: a boolean expression that evaluates to true or false.


Serial.print(val);

Serial.print(val, format);

print: Serial port method. Prints data to the serial port as human-readable ASCII text.

val: 1st Argument of print method, the value to print. Allowed data types: any data type.

format: 2nd Argument of print method, specifies the number base (for integral data types). Permitted values are BIN(binary, or base 2), OCT(octal, or base 8), DEC(decimal, or base 10), HEX(hexadecimal, or base 16). For floating point numbers, this parameter specifies the number of decimal places to use.

Return: returns the number of bytes written, though reading that number is optional. Data type: size_t.


Serial.println(val);

Serial.println(val, format);

println: Serial port method. Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or '\r') and a newline character (ASCII 10, or '\n').


Escape Characters:

Linefeed/New Line means to advance downward to the next line.

Carriage return means to return to the beginning of the current line without advancing downward.

Tab means to leave four spaces.

Form feed (\f or 0x0C) means advance downward to the next "page".

Related Topics:

  1. Arduino IDE.

  2. Arduino Blink.

  3. Arduino Serial.