hi guys,
i have made a robot that does adaptive mapping on a 15x15 grid,
but i want the robot to be able to transfer the map to the computer,
i have no idea about the most economical way/ any way.
hi guys,
i have made a robot that does adaptive mapping on a 15x15 grid,
but i want the robot to be able to transfer the map to the computer,
i have no idea about the most economical way/ any way.
here is the part in the arduino
int Map[15][15];
void setup()
{
Serial.begin(9600);
}
void sendMap()
{
for (int H=0; H<15;H++)
{
for (int W=0; W<15;W++)
{
delay(5);
Serial.println(Map[H][W]);
}
}
}
processing
import processing.serial.*; // import serial library
Serial myPort; // declare a serial port
int[][] distances = new int[15][15];
float maxDistance;
int x, y;
void setup() {
// setup the background size, colour and font.
size(15*30+30, 15*30+30);
background (0); // 0 = black
// setup the serial port and buffer
myPort = new Serial(this, "COM10", 9600);//i am using com port 10
myPort.bufferUntil('\n');
}
/* draw the screen */
void draw() {
for(int i=0; i<15; i++)
{
for(int j=0; j<15; j++)
{
switch (distances[j][i])
{
case 1: // if the value in the array is a 1 then change the background colour
{
noStroke();
fill(0, 0, 254);
rect(j*30+10,i*30+10,20,20);
fill(200, 200, 200);
text(Integer.toString(distances[j][i]), j*30+10, i*30+10, 40, 40);
}
break;
default:
{
noStroke();
fill(100, 100, 100);
rect(j*30+10,i*30+10,20,20);
fill(200, 200, 200);
text(Integer.toString(distances[j][i]), j*30+10, i*30+10, 40, 40);
}
break;
}
}
}
}
/* get values from serial port */
void serialEvent (Serial myPort) {
String xString = myPort.readStringUntil('\n'); // read the serial port until a new line
if (xString != null) { // if theres data in between the new lines
xString = trim(xString); // get rid of any whitespace just in case
distances[x][y] = Integer.parseInt(xString); // set the values to variables
x++;
if (x==15)
{
x=0;
y++;
if (y==15)
y=0;
}
}
}
Glad you found time to share your insight.
which insight would that be XD
i am still getting it to work every time, and i have been down the coast for easter,
and i am going to add a Bluetooth and make a vid when i have it working properly
Do you have a reading comprehension issue?
i have no idea about the most economical way/ any way.
solved
Glad you found time to share your insight.
which insight would that be
What did you do to solve your problem? What should other people who have a similar issue, and who find your thread, do? Solve it themselves, too?
ok,
it is up,
i wanted to know if he wanted the adaptive mapping code or the transfer code