How to Get a String or Number into the Arduino from the Serial Port

Arduino boards such as the Arduino Uno have a serial port that is linked to the USB port on the board. When data is sent out of the serial port in an Arduino sketch using a function such as Serial.print(), then the data goes out of the Atmel AVR microcontrollers (which is the main Arduino microcontroller) serial port to the small Atmel microcontroller on the board that handles the USB communications. This small microcontroller then sends the serial data out of the USB port.

The data that is sent out of the Arduino USB port can be displayed in the Serial Monitor window of the Arduino IDE as shown in the image below.

Opening the Arduino Serial Monitor window.

Opening the Arduino Serial Monitor window.

Data can also be sent from the Arduino IDE Serial Monitor window into the Arduino. Part 19 of the Arduino programming course shows how to send a character, string and number from the Arduino Serial Monitor window to the Arduino board.

A single character is easy enough to receive and process in an Arduino sketch. A string requires a bit more work because it must be assembled from the characters received via the serial port. A number is captured as a string and then must be converted from a series of characters into an actual number.

Go to the tutorial (part 19 of the Arduino programming course) to learn how to handle Arduino serial input →

Arduino Programming: Passing a value to and Returning a Value from a Function

Two new sections have been added to the Arduino Programming Course. The course now looks at how to write a function, pass a value to a function and return a value from a function.

These new parts are available on the Starting Electronics website:

Functions and passing a value to a function looks at the structure of a function, how to write a function and how to pass a value to a function.

Returning a value from a function shows how to return a value from a function and uses an example of calculating the area of a circle by passing the radius of the circle to the function.

Basic Test for the GT-511C3 Fingerprint Scanner Module

The article on testing the GT-511C3 fingerprint module uses an Arduino Uno to test that basic communications are working on the module. This can be used to test that the module is correctly wired and also that it is working.

Sending a character from the Serial Monitor window of the Arduino IDE starts the test by sending a “open” command packet to the fingerprint module. If the fingerprint module is working, it should send back an acknowledge packet and an information packet that are both displayed as hexadecimal bytes in the Serial Monitor window.

Go to article and Arduino sketch →

Learn to Program the Arduino

Learn to write your own sketches for the Arduino in this multi-part course. No previous programming experience is needed.

The Arduino programming course consists of the following parts:

Each new part of the course will be added to his blog post as it becomes available.

You may find the Arduino Language Reference on the Arduino website helpful during the course.



Two Temperature Gauge Arduino Web Server

This two temperature sensor Arduino Ethernet web server uses an Arduino, Ethernet shield and two MCP9700 temperature sensors to measure two temperatures.

The temperatures are displayed on two gauges on the web page hosted by the Arduino web server. The two sensors can be used to measure an inside temperature (e.g. inside a building or room) and an outside temperature (e.g. outside air temperature).