Using the Arduino Serial Port




The Arduino Uno can send data (such as a text message) to the PC over the USB cable. The Arduino IDE has a serial monitor window that can be opened and will receive and display the data sent from the Arduino board. Data can also be sent to the Arduino board from the serial monitor.

Using the Arduino Serial Port




This serial communication is very useful for controlling electronics that is connected to (interfaced to) the Arduino board from the PC. It can also be used to debug (find errors in) Arduino programs when writing new programs.

The following videos show what you will achieve in this tutorial.

Prerequisites

Complete tutorial 3 – Starting with Arduino before attempting this tutorial.

Components

All that is needed is an Arduino Uno board, standard USB cable and PC with the Arduino IDE software installed. You will already have these if you have completed tutorial 3.

Sending Data to PC from the Arduino

Copy the serial_tx_msg Arduino sketch below and paste it into the Arduino IDE.

/*--------------------------------------------------------------
Program:     serial_tx_msg
(serial transmit message)
Description:  Sends a text message out of the serial (USB)
port of the Arduino every second.
Use the Arduino Serial Monitor to receive the
message.
Date:         3 March 2012
Author:       W.A. Smith, http://startingelectronics.com
--------------------------------------------------------------*/
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println("Hello, world!");
delay(1000);
}Compile the program by clicking the "Verify" button in the Arduino IDE. Upload the program to the Arduino board by clicking the "Upload" button.

Now start the serial monitor by clicking the “Serial Monitor” button in the Arduino IDE. The figure below shows the location of the serial monitor in Arduino IDE version 1.0 (top) and Arduino IDE version 0022 (bottom).

 

For more detail: Using the Arduino Serial Port

 




Clip to Evernote

Leave a Comment

(Spamcheck Enabled)

Read previous post:
F*watch – a fully open electronic watch
F*watch – a fully open electronic watch

F*watch is a fully open electronic watch project featuring an integrated GPS receiver. The development started at CERN as an...

Close
Scroll to top