Ard_O_Scope: An Extremely Simple Voltage Visualizer (oscilloscope) for Arduino

12 07 2010

While I was investigating some noise-filtering and smoothing algorithms for analogRead in Arduino, I realized that I needed some way to test the influence of some parameters over a certain signal. I usually do this just by sending the reading of a potentiometer through the serial port of the Arduino and see how these number changed while sweeping my potentiometer.

But this is not a very graphical way to see a signal, so I wanted something similar to an oscilloscope, to to see the data I was pushing through the serial port in a comfortable way. So with only some lines of code I have created a nice arduino voltage visualizer, in the Old School way: It just prints to the Arduino serial console a real time bar chart with the readings of your input, with a refresh frequency of about 350 samples per second (When using 115200 bauds). No comparison with an oscilloscope, but useful when measuring inputs from potentiometers or LDRs…

Watch it in action after the break!

Here is an example of the output of the program:

Extremely Simple Voltage
visualizer for Arduino

Created by Sergio Vilches
--------o                 1.67 V
--------o                 1.50 V
-------o                  1.38 V
------o                   1.26 V
------o                   1.11 V
-----o                    0.92 V
----o                     0.72 V
---o                      0.55 V
--o                       0.42 V
--o                       0.37 V
-o                        0.37 V
-o                        0.39 V
-o                        0.73 V
--o                       1.46 V
-----o                    2.39 V
--------o                 3.06 V
-----------o              3.46 V
--------------o           3.68 V
----------------o         3.93 V
-----------------o        4.22 V
-------------------o      4.45 V
--------------------o     4.55 V
---------------------o    4.50 V
---------------------o    4.12 V
--------------------o     3.59 V
------------------o       2.94 V
----------------o         2.35 V
-------------o            1.70 V

And here is the sketch:

      Extremely Simple Voltage Visualizer (oscilloscope) for Arduino
  This program shows the (smoothed) reading of analog input (0) as an horizontal bar chart in the Serial Monitor of Arduino.

  The circuit:
  Analog sensor (potentiometer will do) attached to analog input 0

  Created 12 July 2010
  By Sergio Vilches
  This sketch is in the public domain. Feel free to modify or distribute it. Have fun!


int val;
int ScreenWidth = 25;  // Use this parameter to choose the maximum number of characters that will be sent for each reading
                       // (the number of "-"). Please note that the sampling frequency will decrease when using a large value.

float smoothingFactor = 0.5; //Vary this value from 0 (no smoothing of the signal) to 0.99 (a lot of smoothing). 0.8 works well

void setup()
  val = analogRead(0) * ScreenWidth / 1024.0;

  //Let's print a heading
  Serial.println("Extremely Simple Voltage");
  Serial.println("visualizer for Arduino");
  Serial.println("Created by Sergio Vilches");

void loop()
  val = (smoothingFactor * val + (1-smoothingFactor) * analogRead(0) * ScreenWidth / 1024.0) ;  //This line smooths the data

  for (int i = 0 ; i < val ; i++)    //We print as many "-" as val

  Serial.print("o");    //We print the marker

  for (int i = 0 ; i < ScreenWidth - val ; i++)
    Serial.print(" ");

  Serial.print(analogRead(0)*5/1024.0);  //And the voltage of the reading
  Serial.println(" V");

Here is the result of measuring the voltage output from a slider, using a serial speed of 9600 bauds. You can improve the sampling speed by changing this value in void setup, setting Serial.begin(115200).




13 responses

13 07 2010

Ehhh cuando tienes los campos? Cierra ya y bajate un dia 😀

(el Click here if you want to see my blog in English! empieza a perder sentido XDDD)

14 07 2010

Que va!
Yo creo que google translate traduce mejor que yo al inglés!!
Y no te preocupes que bajo pronto!


29 10 2012
Juan José

Pero no sale bien cuando aumento de 9600 a 14400 o 115200…..¿ Por qué ?

29 10 2012
Juan José

But, the serial grap don´t work on 14400 0 115200 ( serial.begin () )

3 11 2012
3 11 2012

Reblogged this on Prototalk.

22 12 2012

Good day! Would you mind if I share your blog with my myspace
group? There’s a lot of folks that I think would really appreciate your content. Please let me know. Thanks

18 01 2013

I do agree with all the ideas you have presented in
your post. They’re really convincing and will definitely work. Still, the posts are too short for newbies. Could you please extend them a bit from next time? Thanks for the post.

21 01 2013

Hello! I know this is somewhat off topic but I was wondering
if you knew where I could get a captcha plugin for my comment form?
I’m using the same blog platform as yours and I’m having trouble
finding one? Thanks a lot!

31 01 2013
define telepathy

Appreciate your discussing Ard_O_Scope: An Extremely Simple Voltage Visualizer (oscilloscope) for Arduino Warranty Voider.
Now I am completely astounded that somebody would piece of writing something similar to this.

The situation reminds myself a bit of budget building
insurance but that is an alternative adventure entirely.
Enjoy a terrific day!

20 08 2015
Shai Perednik

This is great, ty! I need a quick oscope to troubleshoot a pot and DAC and this quickly helped!

12 09 2016
hearthstone deck tracker

hearthstone deck tracker

Ard_O_Scope: An Extremely Simple Voltage Visualizer (oscilloscope) for Arduino | Warranty Voider

7 10 2016
hearthstone reddit guide

hearthstone reddit guide

Ard_O_Scope: An Extremely Simple Voltage Visualizer (oscilloscope) for Arduino | Warranty Voider


Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de

Estás comentando usando tu cuenta de Cerrar sesión /  Cambiar )

Google photo

Estás comentando usando tu cuenta de Google. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )

Conectando a %s

A %d blogueros les gusta esto: