How to Send Data to and fro with Arduino Uno

How about your Arduino communicating with a computer? If you look at the Arduino UNO you can see there is a Tx and Rx pin on digital pin 1 and 0. You can use them while you are running your program for output and input. When you call the serial functions in the Arduino programming language you are basically using these pins to talk back and forth between the computer and Arduino. You will notice that the Tx and Rx LED’s will flash to indicate that you are sending or receiving data.

Arduino Serial Communication

Every Arduino board has at least one Serial communications chip-on-board, called a UART (Universal asynchronous receiver/transmitter). UART is a piece of hardware that takes away the clock and sends the data at a preset speed. This process requires extra data to be sent in lieu of the reliability that a clock provides. The extra data we send are all mechanisms to ensure error-free data transfers, and they are:

Data Bits – This is the actual information we send, can be 5-9 bits long.

Synchronization bits – These are the start and stop bits transferred with each chunk of data. They let the receiver know that data is coming and when it has finished transmitting.

Parity Bits –  Parity bits are determined using odd or even logic after adding each 1 from the data chunk. It is a method of error checking that slows your data transfer and you will need a method to resend incorrect data.

Baud Rate – The baud rate is the speed at which both devices agree to send and receive data at. Think of this as a clock signal that you sent and forget. It is measured in bits per second.

When connecting devices using UARTs the Transfer pin of one device will connect to the Receive pin of the other and vice versa. This is pretty logical when you think about it. We are going to use the USB port on our Arduino to communicate with the Serial Monitor within the Arduino IDE.

The first tool we will be using is the Serial.begin. We know that the Baud Rate is a measurement of data transferred over time, bps in particular (bits per second). We can use any value for baud rate in this example as we are going to configure both devices. Generally, the value of 9600 is used as the Baud Rate because it’s a standard value.

That command initializes our serial communications, now we can do two more things:

  1. Listen for any data being transferred from the Arduino
  2. Print that data inside our Serial Monitor.

Simple program to send and receive data with Arduino UNO

//define our incoming data as an integer

//this will correspond to a ASCII value

int incomingdata = 0;

void setup() {

  //Start serial communications using baud rate of 9600



void loop() {

  //Only write data to serial monitor if data is received

  if (Serial.available() > 0)


    //assign the value being read over serial to the incomingdata variable

    incomingdata =;

    //Print the value you entered back to the screen, char()

    //enables you to print the character not the ASCII value

    //stored for the entered value



Verify your code, upload it to your board and wait until it is complete.

Then click the Serial Monitor button in the top right of your Arduino IDE.

You will have a text box at the top of the screen with a send button at the end of the line, then a big white space with nothing in it.

Type something into the text box and your Arduino should say it back to you, that’s what we call an Echo, the computer is outputting what you input.

Congratulations, you now have a basic understanding of how we send data to and fro with Arduino!

Naina Roy

Naina Roy

Naina is a freelance writer.She specializes in best marketing practices and entirely fills in with deep research on cyberbullying, trolling, employee legal facts, social media and Instant messengers.
Naina Roy

Leave a Reply

Your email address will not be published.