
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 vlxs.wordpress.com --------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:
/* Ard_o_Scope 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 http://vlxs.wordpress.com 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() { Serial.begin(9600); val = analogRead(0) * ScreenWidth / 1024.0; //Let's print a heading delay(500); Serial.println("--------------------------"); Serial.println("Extremely Simple Voltage"); Serial.println("visualizer for Arduino"); Serial.println("--------------------------"); Serial.println(); Serial.println("Created by Sergio Vilches"); Serial.println("vlxs.wordpress.com"); delay(1500); } 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("-"); 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).




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)
Que va!
Yo creo que google translate traduce mejor que yo al inglés!!
Y no te preocupes que bajo pronto!
Saludos!
Pero no sale bien cuando aumento de 9600 a 14400 o 115200…..¿ Por qué ?
But, the serial grap don´t work on 14400 0 115200 ( serial.begin () )
[...] http://vlxs.wordpress.com/2010/07/12/ard_o_scope-2/ [...]
Reblogged this on Prototalk.
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
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.
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!
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!