Using the Arduino serial console to monitor your Sketch

By: ( +David Herron; Date: July 6, 2017

Tags: Arduino

The most useful debugging tool many programmers have is the Print statement. They insert Print statements throughout their code, to see if the program got to certain points and if so what was the values. While there are fancy schmancy debugger packages available, the Print statement is extremely useful and simple. An Arduino presents a challenge because the software executes over on that teensy board, there's no computer display, no direct connection, where would the print statement send its output? Turns out the Arduino software stack includes a Serial console that you can view from inside the Arduino IDE. What we'll do in this article is go over a trivial example of reading an analog value to print on the serial console.

Built-in to the Arduino IDE is the capability for a Sketch to output through the USB connection to the Arduino serial console in the IDE.

Click this button to open the serial console
The serial console window. It displays text received from the Arduino, and apparently allows you to type lines of text to the Arduino

The Arduino Playground ( has more ideas on interfacing an Arduino to the Serial port on another computer to interact with software on an Arduino. For our purposes, the simple Serial Console provides an easy way to get messages out of an Arduino.

To explore this we'll set up a simple Arduino program to read some data, displaying it through the Serial port.

The circuit

Wiring for simple analog circuit to read value of a potentiometer
Closeup of wiring the potentiometer

We wire a Potentiometer so that one end is connected to the +5 volt pin, the other end is connected to the Ground pin, and the middle pin (the wiper) is connected to analog pin A0.

There's a huge range of possible sensors and such that can be connected to an Arduino. This is one of the simplest, but as we go through the following Sketch imagine other possible sensors.

The wiring for this is easily accomplished on a simple prototyping breadboard. It was fortunate the surface-mount potentiometer I happened to have fit with the holes on the breadboard. Wired as so, a simple screwdriver is enough to adjust the potentiometer, and pin A0 will receive a variable voltage depending on where the potentiometer is turned.

The Sketch

Now let's look at how we read the analog data, and print to the serial console.

int sensorPin = A0;  

void setup() {

void loop() {
  // read the value from the sensor:
  int sensorValue = analogRead(sensorPin);

The setup function simply initializes the Serial connection. We've set it to 9600 baud, so set the Console to the same data rate.

In loop we use analogRead to read pin A0 giving us an int from 0 to 1023. We print the value using Serial which goes out to the serial console as previously configured.

A call to delay keeps the data being printed at a reasonable rate.

You may want to convert the 0..1023 value into a voltage. We know from the circuit the value represents a voltage between 0 to 5 volts. Some division and conversions are required, which is an exercise for the reader.

A common application is to have multiple sensors, and a line-by-line output of data, with an easily generated and easily parsed format. For example a timestamp followed by several numerical values all separated by a space or tab character. The serial line outputting this data could be connected to another device that records the outputted data. There might even be commands sent to the device to cause relays to open or close. Arduino's are capable of this sort of thing.


Arduino Tutorial - analogRead Serial Monitor with Potentiometer - YouTube

Source: ( Mert Arduino and Tech

Arduino Basic Tutorial analogRead Serial Monitor with Potentiometer Flash Deals -- Mega Stock Clearance -- Arduin...

Tutorial 09: How to read voltages with analogRead(): Arduino Course for Absolute Beginners (ReM) - YouTube

Source: ( Programming Electronics Academy

*Click Below to Sign up for the free Arduino Video Course:* *Click Below to Check Out the Premium Ardui...
« Correct character encoding with DOMDocument implementing a Wordpress content filter Initial notes on using MAX485 based TTL-to-RS485 adapter boards with Arduino or Raspberry Pi »
2016 Election Acer C720 Ad block AkashaCMS Amazon Amazon Kindle America Amiga Android Anti-Fascism AntiVirus Software Apple Apple Hardware History Apple iPhone Apple iPhone Hardware April 1st Arduino ARM Compilation Astronomy Asynchronous Programming Authoritarianism Automated Social Posting Ayo.JS Bells Law Big Brother Big Finish Bitcoin Mining Black Holes Blade Runner Blockchain Blogger Blogging Books Botnet Botnets Cassette Tapes Cellphones Christopher Eccleston Chrome Chrome Apps Chromebook Chromebooks Chromebox ChromeOS CIA CitiCards Citizen Journalism Civil Liberties Clinton Cluster Computing Command Line Tools Comment Systems Computer Hardware Computer Repair Computers Cross Compilation Crouton Cryptocurrency Curiosity Rover Currencies Cyber Security Cybermen Daleks Darth Vader Data backup Data Storage Database Database Backup Databases David Tenant DDoS Botnet Detect Adblocker Developers Editors Digital Photography Diskless Booting Disqus DIY DIY Repair DNP3 Do it yourself Docker Docker MAMP Docker Swarm Doctor Who Doctor Who Paradox Drobo Drupal Drupal Themes DVD E-Books E-Readers Early Computers Election Hacks Electric Bicycles Electric Vehicles Electron Emdebian Encabulators Energy Efficiency Enterprise Node EPUB ESP8266 Ethical Curation Eurovision Event Driven Asynchronous Express Facebook Fake News Fedora VirtualBox File transfer without iTunes FireFly Flickr Fraud Freedom of Speech Gallifrey git GitKraken Gitlab GMAIL Google Google Chrome Google Gnome Google+ Government Spying Great Britain Heat Loss Hibernate Hoax Science Home Automation HTTP Security HTTPS Human ID I2C Protocol Image Analysis Image Conversion Image Processing ImageMagick In-memory Computing InfluxDB Infrared Thermometers Insulation Internet Internet Advertising Internet Law Internet of Things Internet Policy Internet Privacy iOS Devices iPad iPhone iPhone hacking Iron Man Iternet of Things iTunes Java JavaScript JavaScript Injection JDBC John Simms Journalism Joyent Kaspersky Labs Kindle Kindle Marketplace Lets Encrypt LibreOffice Linux Linux Hints Linux Single Board Computers Logging Mac Mini Mac OS Mac OS X Machine Learning Machine Readable ID macOS MacOS X setup Make Money Online March For Our Lives MariaDB Mars Matt Lucas MEADS Anti-Missile Mercurial Michele Gomez Micro Apartments Military Hardware Minification Minimized CSS Minimized HTML Minimized JavaScript Missy Mobile Applications MODBUS Mondas Monetary System MongoDB Mongoose Monty Python MQTT Music Player Music Streaming MySQL NanoPi Nardole NASA Net Neutrality Node Web Development Node.js Node.js Database Node.js Testing Node.JS Web Development Node.x North Korea npm NVIDIA NY Times Online advertising Online Community Online Fraud Online Journalism Online Photography Online Video Open Media Vault Open Source Open Source Governance Open Source Licenses Open Source Software OpenAPI OpenVPN Paywalls Personal Flight Peter Capaldi Photography PHP Plex Plex Media Server Political Protest Postal Service Power Control Privacy Production use Public Violence Raspberry Pi Raspberry Pi 3 Raspberry Pi Zero Recycling Refurbished Computers Remote Desktop Republicans Retro Computing Retro-Technology Reviews Right to Repair River Song Robotics Rocket Ships RSS News Readers rsync Russia Russia Troll Factory Russian Hacking SCADA Scheme Science Fiction Search Engine Ranking Season 1 Season 10 Season 11 Security Security Cameras Server-side JavaScript Shell Scripts Silence Simsimi Skype SmugMug Social Media Social Media Warfare Social Networks Software Development Space Flight Space Ship Reuse Space Ships SpaceX Spear Phishing Spring Spring Boot SQLite3 SSD Drives SSD upgrade SSH SSH Key SSL Stand For Truth Swagger Synchronizing Files Telescopes Terrorism The Cybermen The Daleks The Master Time-Series Database Torchwood Total Information Awareness Trump Trump Administration Trump Campaign Ubuntu Udemy UDOO Virtual Private Networks VirtualBox VLC VNC VOIP Web Applications Web Developer Resources Web Development Web Development Tools Web Marketing Website Advertising Weeping Angels WhatsApp Window Insulation Windows Windows Alternatives Wordpress World Wide Web Yahoo YouTube YouTube Monetization