We are about to switch to a new forum software. Until then we have removed the registration on this forum.
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
Please edit your post, select your code and hit ctrl+o to format your code. Make sure there is an empty line above and below your code. You can do this also for your arduino code.
You should consider checking the next post to manage data arriving from your arduino:
https://forum.processing.org/two/discussion/16618/processing-with-arduino-void-serialevent#Item_1
Just to clarify, did you have a question regarding your code?
Kf
Thanks for your response. The code I posted works fine but the timebase is too slow to be useful. However, a friend of mine did some homework and came up with https://sourceforge.net/projects/scopino/ which is a free download giving a much faster timebase, 5ms per division. This consists of an Arduino sketch and an exe file and is extremely effective. Peter H