I wrote a program that graphs voltages in real time coming from an accelerometer which then are looped every time they go all the way across the screen. The problem is that when the loop happens, the lines that represent the voltages remain where they are, that is, they start over again but overlapping the voltages in previous loops. In the end the screen gets pretty busy with lines on top of other lines which makes everything really messy.
I could copy and past my code but there are things that don't belong to Processing, at this point I'm only working from Java but using the Processing package, so the code has unfamiliar things to the Processing syntax. A guy from this forum helped with a previous problem I had in this program, he helped me out with this, which is the basic principle:
[code]
int a;
int sec;
int olda = 0;
int oldsec = second();
void setup() {
background(102);
size(500, 500);
}
void draw() {
a+=1;
sec = second();
line(olda, oldsec*4, a, sec*4);
olda = a;
oldsec = sec;
}
[/code]
How can I clear the screen so that when the lines reach the width of the screen they dissapear and then appear right at the beginning?
Can anybody tell me how to draw more than one cube in Processing, for example, one next to the other? I noticed that "box()" doesn't have parameters for the coordinates, is it something to do with "translate()"?
I'm new to Processing and there's something I've been trying to do but I need help, please take a look at this code:
[code]
int a;
int sec;
void setup(){
size(500,500);
}
void draw() {
background(102);
a+=1;
sec =300;
sec = second();
line(50, 300, a, sec*4);
}
[/code]
In my university project I want to represent Voltage vs. Time and I'm trying to achieve this in Processing. Say that, instead of "sec*4" I had voltage readings coming from a sensor, I want to be able to see what the voltage looks like from time = 0 onwards. The problem of the simple code I just pasted is that the function "line()" does not leave the traces of "sec*4" but instead, the line is shifted down every second. I found a similar code to what I'm looking for but the the program uses the mouse to draw lines:
Can anybody tell me if it is possible to export data from Processing to Excel? I've been looking for libraries or documentation on that but I haven't succeeded. If it is not possible, are there any alternatives? thanks!