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.
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