Hello,
The graph you made is perfect, but I implemented the code and I don’t get a point in the graph.
The code on the arduino uno works great and gives out points, but the point don’t come back in the graph.
I have put that last bit of code in there, but it still doesn’t work, so could you please help me this one last time?
import processing.serial.*;
Serial myPort; // maakt een object van seriele poort
String val; //ontvangt de data van de seriele poort
float x=0, y=0;
float space = 25; //grootte hokjes
void setup ()
{
size (1050, 1050); // maak het canvas
background(255);
String portName = Serial.list() [0]; // de 0 moet worden veranderd in de poort
myPort= new Serial(this, portName, 9600);
}
void draw ()
{
background(255);
fill(0);
textSize(10);
for (float xx=25; xx<=1025-space; xx+=space) { // x-as
for (float yy=25; yy<=1025-space; yy+=space) { // y-as
line(xx, yy, xx, yy+space);
line(xx, yy, xx+space, yy);
if (xx == 25) text((int)(yy-space), xx-space, yy);
else if (yy==25) text((int)(xx-space), xx, yy);
}
line(25, 1025, 1025, 1025);
line(1025, 25, 1025, 1025);
}
if (myPort.available() > 0) //als data beschikbaar is
{
val = myPort.readStringUntil('\n'); // lees het uit en sla het op in val
if (val != null) // Als er waardes worden uitgelezen gaat de hier in
{
float [] list = float( split (val, ",")); // data verkregen van arduino wordt bij de komma gesplitsd.
println(val); // print het uit op het console
x = list[0]; //part1 wordt de de eerst afkoppeling opgeslagen
y = list[1]; // part2 wordt de tweede afkoppeling opgeslagen
}
}
x = map(x,0,1000,25,1025); //and
y = map(y,0,1000,25,1025);
point (x, y);
}