Serial Communication Using State Machine

by Alex

April 03 2020 Robotics


This is an example for serial communication with the state machine.

Full text

In this example, we will be establishing a soft serial and hard serial for transmitting the information using the state machine. We will be using only one board for this example. Please go through this tutorial before looking at this example.


You will need an Arduino Uno for this tutorial.

  • Pin 0 is the RX pin for hardware serial, which is used to receive input messages to your computer.
  • Pin 1 is the TX pin for hardware serial, which is used to send output messages out of your computer.
  • Since we only have one board, you will have to choose two other pins to use for your software serial. I chose pin 11 as the software serial RX pin, and pin 10 for the TX pin. These function the same as the hardware serial pins.
  • We will need pin 0 to receive input because it is the hardware RX pin, and we will need pin 10 to send data out to be received by the RX pin.


Include SoftwareSerial.h and Arduino.h


  • Plug the Arduino into your computer and press on the serial port on VS code.
  • You should see it keep printing the receive buffer, which in this case is 1 2 3 4 5. If you do not see this, check to make sure that your wires are connected to the correct pins.
  • Try disconnecting one end of the wire connecting pin 0 to pin 10. The serial port should stop printing numbers. After reconnecting it, it should continue printing.

I hope this helps you with your programming using the state machine in your serial communication. Good luck, and have fun.

About the author

Alex - CEO of Alex Co.

Strong minded an self motivated, Alex is destined to great accomplishments.