I’m sorry, i don’t quite get what you want… What you are describing is exactly a coordinate system…
I’ll just make the most basic setup to get what you described.
void setup() {
size(600, 600);
}
void draw() {
int inputX = (int)random(0, 1000);//replace this with the X coordinate you get
int inputY = (int)random(0, 1000);//replace this with the Y coordinate you get
for (int x = 0; x <= 10; x++) {
text(x*100, x*50 + 20, 540);
line(x*50+20, 20, x*50+20, 520);
}
for (int y = 0; y <= 10; y++) {
text((10-y)*100, 0,y*50+30);
line(20, y*50+20,520, y*50+20);
}
point(inputX/2 + 20, inputY/2 + 20);
}
so it will look like this :
import processing.serial.*;
Serial myPort; // maakt een object van seriele poort
String val; //ontvangt de data van de seriele poort
void setup ()
{
size (1000,1000); // maak het canvas
String portName = Serial.list() [0]; // de 0 moet worden veranderd in de poort
myPort= new Serial(this, portName, 9600);
float y =0;
float x=0;
float space = 25; //grote hokjes
float len1 = 400; // aantal hokjes y- as
float stopX = 5.960296; // Maximum x-as
float len2 = stopX-x; // aantal hokjes x-as
float stopY = 50.882125; // Maximum Y-as
for (float xx=75; xx<=stopX; xx+=space) // x-as
{
line(xx, y, xx, y+len1);
}
for (float yy=125; yy<=stopY; yy+=space) //y-as
{
line(x, yy, x+len2, yy);
}
}
void draw ()
{
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
float part1 = list[0]; //part1 wordt de de eerst afkoppeling opgeslagen
float part2 = list[1]; // part2 wordt de tweede afkoppeling opgeslagen
float X= part1; // part1 wordt opgeslagen als X
float Y= part2; // part2 wordt opgeslagen als Y
}
}
background(255);
fill(205,61,62); //Rood vierkant gemaakt
rect(100, 250, 800, 500);
fill(150,255,0);
rect(125,275,750,450); // groen vierkant wordt gemaakt
fill(0);
textSize(40);
text("GPS Tracker", 350, 220); //Tekst wordt geschreven
fill(0, 0, 255);
for (int x = 0; x <= 10; x++) {
text(x*100, x*50 + 20, 540);
line(x*50+20, 20, x*50+20, 520);
}
for (int y = 0; y <= 10; y++) {
text((10-y)*100, 0,y*50+30);
line(20, y*50+20,520, y*50+20);
}
point (X/2 + 20,Y/2 + 20); // need to add 20 as offset and divide by 2 because its scaled to half the size...
}