Grapher for IR-Distance sensor

GraphSerial.pde (2013Bytes)

Yesterday I mounted a Sharp GP2D12 on a servo and I thought of mapping the area in front of the sensor (at least at a certain height) to use them with a bot and I wanted to know how the bot "sees" his environment.

The software for the ATmega takes readings every 10 degrees and then sends these values to the computer via serial.

Now I have seen alot of cool things done with processing and I thought I'll try it out and what I came up with is basically a graph of the distance "bend" by 180 degrees. The graphed data reminds me of the graph you can find in the datasheet of many ultrasonic sensors like the SRF05.

The next step would be reading the serial data directly into processing and then graph it, but my skills in processing aren't good enough (yet) to do something like this altough I have already tried to do this (any suggestions appreciated!^^)

I dont know if this is relevant to anyone but I thought I'd post it because it does have to do with the often used Sharp IR distance sensors.

 

EDIT 11/15/11: I managed it to add serial support! Now the data received via serial is stored in an array and then plotted until the next data plot is received

Coincidence

I just posted a forum topic asking how this was done. Shoulda read this first, and straight asked you.

How did you do it?

I know how to read analog values into Serial with my Arduino, but sending them to processing?

Re: coincidence

There is a class called Processing.serial which can make contact with the input fron the arduino.

I once used it for a wii chuck adapter, and i used this link:

http://hacknmod.com/hack/how-to-graphically-visualize-data-real-time/

 

Yeah I know that it can be

Yeah I know that it can be done, as I said I have tried it before but the problem I have is converting the received string to an integer and then store that value into an array to plot the graph afterwards.

Will take a look at this.

Will take a look at this. Getting a base setup where you can test sensors would be nice. This could include data from ping sensors as well.

It doesn’t actually matter

It doesn’t actually matter from wich sensor the data is coming, the trick is sending the data to the computer in the correct format. The format is:

Data + \n

Arduino Code:

println(distance, DEC);

AVR-GCC:

itoa(distance, buffer, 10);

sendUSART(buffer);

sendUSART("\n");

 

\n is the new line

\n is the new line character, thats why you need something like println(); on the Arduino.

You need a new line
You need a new line character because the program reads the input string until it reaches \n and then it starts reading the next string until \n and so forth