We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello all, hope I put this in the correct section. I'm very green to coding processing and arduino.
I have found and modified some code I found that suits my needs of taking a digital 1, 0 and plotting it as a square wave.
The problem I am having is when screen is at size 400, 400 the square wave timing is ok but when I change screen size to 1000, 400 the scroll slows resulting in the wave runs together giving what looks like a strait line at 0 and at 1.
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
int [] eecgraph;
int [] icmgraph;
int etapa = 0;
int tA = 0;
int tB = 0;
int tC = 0;
int pipeec = 38;
int pipicm = 39;
void traceBooleanSignal (int [] signal, int ypos, int amplitude, color c1) {
stroke(c1);
for (int i = 1; i < width; i++) {
line(i, ypos+amplitude-signal[i]*amplitude, i, ypos+amplitude-signal[i-1]*amplitude);
}
}
void updateBooleanSignal (int [] signal) {
for (int i = 1; i < width; i++) {
signal[i-1] = signal[i];
}
}
void setup()
{
size(1000, 400);
arduino = new Arduino(this, "COM5", 57600);
arduino.pinMode(pipeec, Arduino.INPUT);
arduino.pinMode(pipicm, Arduino.INPUT);
eecgraph = new int[width];
for (int i = 1; i < width; i++) {
eecgraph[i] = 0;
}
icmgraph = new int[width];
for (int i = 1; i < width; i++) {
icmgraph[i] = 0;
}
}
void draw ()
{
background(0);
if (arduino.digitalRead(pipeec) == Arduino.HIGH) {
eecgraph[width-1] = 1;
}
else {
eecgraph[width-1] = 0;
}
if (arduino.digitalRead(pipicm) == Arduino.HIGH) {
icmgraph[width-1] = 1;
}
else {
icmgraph[width-1] = 0;
}
updateBooleanSignal(eecgraph);
traceBooleanSignal(eecgraph, 150, 40, color(255, 0, 0));
updateBooleanSignal(icmgraph);
traceBooleanSignal(icmgraph, 250, 40, color(0, 255, 0));
}
How would one go about changing the timing so the on and off time is wider? can it be done through an INT so both graphs can be adjusted to the same value at the same time?
Thanks, Dom
Answers
Please format the posted code, so one can try to help you : )
http://forum.processing.org/two/discussion/14/to-newcomers-in-this-forum-read-attentively-these-instructions
Hah sweet thank you.
Ok also here is the link to the original code
openprocessing.org/sketch/42450
Anyone?
Maybe show a line every other pixel instead of every pixel. That way the minimum width is 2 instead of 1.