How to make an oscilloscope display

edited February 2017 in Arduino

It would be really useful to have a virtual oscilloscope for a current Arduino project. Here is an attempt at plotting a serial input from an Arduino which continuously sends the output of a pot. It takes 25 seconds to plot the 1600 points across the screen. Anything less than a second would be good. Any ideas?

import processing.serial.*; // imports library. Unlike Arduino, not auto Serial port; //defines serial object as 'port' float potvalue = 0; //This is the value in the range 0-255 to be read int i = 0; //float yvalues[]=new float[width+1]; void setup () { background(255); size(1600, 500); port = new Serial(this, "COM3",9600); //Opens the port being used and sets rate port.bufferUntil('\n'); } void draw(){ if (i>=1600){ i=0; background(255); } fill(0); point(i,375-potvalue); i=i+1; } void serialEvent (Serial port) { potvalue = float(port.readStringUntil('\n')); }

This is the Arduino Test program:

`int potPin = 0;

void setup() { Serial.begin(9600); }

void loop() { int val = map(analogRead(potPin), 0, 1023, 0, 255); Serial.println(val); }`

Answers

Sign In or Register to comment.