Friday 23 January 2015


6. Serial communications in Arduino

Introduction

Serial communication provides a easy way for Arduino to communicate with the computer and several other devices. The serial communication enables the computer to upload the programs to the computer as well as to send a data to computer.

Arduino IDE provides a serial monitor to display the data which is sent to the computer from the Arduino.


Data can be sent from the computer to the Arduino using the Text box avail on top of the serial monitor.
Baud Rate is selected using the drop down box on the bottom-right.You can use the drop down labelled "NO LINE ENDING"to automatically send a carriage return or a combination of a carriage return and a line at the end of each message sent when clicking the sent button by changing "No line ending"

Sending Information from your computer to your Arduino

Statement

You want to send text or data to be displayed on the PC using the Arduino IDE or the serial terminal program of your choice

Solution


void setup()
{
Serial.begin(9600); //begins a serial communication with the PC with the baud rate as 9600
}
void loop
{
int a;
Serial.print("The number is ");
Serial.print(a);
delay(600);
a=a+1;
}

OUTPUT

  The number is 0
  The number is 1
  The number is 2

// Number keeps on adding '1' and displays the output infinite times