Created on: 2 August 2012
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.
Mar 19, 2015 Data can be sent to the Arduino from the Serial Monitor window in the Arduino IDE. A user can enter data in the input field in the serial monitor window to send values and data to the Arduino. Any serial program, or even a custom serial application can be used to send data to the Arduino instead of using the Serial Monitor window. Except for part 13 of this course, the Serial Monitor window has only. Sending simple serial commands to an Arduino is the easiest way to communicate between an Arduino and a computer. The computer could be a PC, a Raspberry Pi, or any device that communicates with serial. By sending and “decoding” a single character it is easy to add a simple debug menu or even serial menu. Click the serial monitor button in the toolbar and select the same baud rate used in the call to begin. Serial communication on pins TX/RX uses TTL logic levels (5V or 3.3V depending on the board). Don’t connect these pins directly to an RS232 serial port; they operate at +/- 12V and can damage your Arduino board. The IDE’s built-in serial monitor is JUST a simple terminal program. It opens a COM port, sends, and receives data. By using “Serial.begin” you are telling your Arduino to send the computer serial data. Any program on your computer, such as these in this list, that can open a serial port can send/receive data to the Arduino. Visit us on our new web site: www.arduinoprojectgenius.com visit us on our facebook page:arduino, element14.
Transmit a message from the Arduino to the PC:
Receive characters from the PC and transmit a message back to the PC:
Arduino Serial Monitor Send Commands
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.
Amazon.co.uk
Sending Data to PC from the Arduino
Copy the serial_tx_msg Arduino sketch below and paste it into the Arduino IDE.
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).
The serial monitor window should display a new 'Hello, world!' message every second. Note that the TX LED on the Arduino board lights up.
Sending Data from the Arduino to the PC
Copy the serial_rx_msg sketch below and paste it into the Arduino IDE.
This program receives data from the PC and then transmits it back to the PC with an additional message. It demonstrates receiving and transmitting data on the Arduino board.
In the Arduino IDE, verify and then upload the serial_rx_msg program to the Arduino board. Start the serial monitor program and enter a text character or sentence in the top field (to the left of the Send button). Click the Send button (or press Enter) to send the character or sentence.
For each character received, the Arduino board will send back 'You typed: ' and then the character that you typed.
Note that the TX and RX LEDs switch on for a brief moment when clicking the send button. This shows that data was sent and received.
Now that you know how the serial monitor works, we can use it in future Arduino projects.
Please enable JavaScript to view the comments powered by Disqus.
Beginner Tutorials
Electronic Components
Tools
Description
Writes binary data to the serial port. This data is sent as a byte or series of bytes; to send the characters representing the digits of a number use the print() function instead.
Syntax
Serial.write(val)
Serial.write(str)
Serial.write(buf, len)
Parameters
Serial
: serial port object. See the list of available serial ports for each board on the Serial main page.val
: a value to send as a single byte.str
: a string to send as a series of bytes.buf
: an array to send as a series of bytes.len
: the number of bytes to be sent from the array.
Returns
Arduino Serial Monitor Send Sms
write()
will return the number of bytes written, though reading that number is optional. Data type: size_t
.