Skip to main content

Messaging

Serial communication is a method for two devices to communicate with each other. In Code Kit, you can use the serial blocks to send and receive data between the microcontroller and your computer.

If you are using Code Kit Pro or Code Kit Classroom, you can use the built-in serial monitor to send and receive data.

Serial begin

The serial begin block opens a serial communication channel between the board and a connected device (probably your computer).

The speed (baud rate) is the rate at which data is transferred in a communication channel. The speed is measured in bits per second (bps). Common speeds are 9600 and 115200.

tip

For communication to work, the speed on the board and the connected device must match. If the speed is different, the data will be garbled.

Serial timeout

The serial timeout block sets a time limit for waiting to receive data. This time limit applies to any block that reads data from the serial port.

The timeout is the maximum time to wait for data in milliseconds.

Serial print

The serial print block sends data to the connected device. If you are using Code Kit Pro or Code Kit Classroom, the data will be displayed in the serial monitor.

  • value: The data to send. This can be text, a number, or a variable.
  • new line: If checked, a new line character will be sent after the data.

Serial print value

The serial print value block outputs the value of a variable over the serial port.

info

If you are using Code Kit Pro or Code Kit Classroom, you can use the serial print value block to graph the value of a variable in the serial monitor.

The graph will update in real-time as the variable changes. Using multiple instances of this block allows you to graph multiple variables at the same time.

Serial send byte

The serial send byte block sends a byte of data to the connected device. A byte is an 8-bit unit of data.

Get bytes available

The get bytes available block returns the number of bytes (characters) available to read from the serial port.

Check for serial data

The check for serial data block checks if there is data available to read from the serial port.

The block outputs true if there is data available, and false if there is no data available.

Read serial data until character

The read serial data until block reads data from the serial port until a specified character is received. The block will wait for data to be available if there is none.

  • character: The character to read until. The block will keep reading data until this character is received.

The block outputs the data as text.

Read serial data

The read serial data block reads data from the serial port. The block will wait for data to be available if there is none.

The block outputs the data as text.

Serial read byte

The serial read byte block reads a byte of data from the serial port. The block will wait for data to be available if there is none.

The block outputs the data as a number.

Read serial data as number

The read serial data as number block reads data from the serial port and converts it to a number. The block will wait for data to be available if there is none.

The block outputs the data as a number.