Help with a graph in Processing
in
Programming Questions
•
2 years ago
Hey guys,
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:
[code]
void setup() { size(640, 200); background(102); } void draw() { stroke(255); if(mousePressed) { line(mouseX, mouseY, pmouseX, pmouseY); } }
[/code]
Using the same principle of the code above, how can I write a program that leaves the changes in voltage on the screen?
I'll be very thankful if you can help me out. Again, I'm new to Processing but I need to achieve this somehow.
1