Ping))) Processing : Arduino

edited December 2013 in Arduino

EDIT: Managed to run an example using both sketches. I wasn't understanding the order of code to input in which program.

I'm trying to connect an Arduino sketch to Processing using the Processing 2.0 Serial library. I'm trying to get data from an Ultrasonic Range Sensor (#28015) (http://arduino.cc/en/Tutorial/ping), and use this to run a sketch in Processing. I've been advised using the Arduino (Firmata) library isn't possible with this type of sensor.

At the moment I'm using an example Processing sketch to establish a connection to an Arduino (http://processing.org/reference/libraries/serial/serialEvent_.html).

My issue is that I'm trying to read data values for distance in cm in my Processing sketch, yet from the example references in the links I'm only given a demonstration of how to read values directly from a signal pin (I'm fairly new to Processing and Arduino).

I was hoping if anyone might have any tips or advice on how to get Processing to print out values from an Arduino linked to an Ultrasonic Range Finder?

Regards

Answers

  • Read these tutorials https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing/to-processing. Send the value via Serial from arduino and get it in processing the same way

  • Go into your processing software and pull up the SimpleRead code rather than the SerialEvent code. It will be in the same place Examples/libraries/serial/SimpleRead. They even have the arduino code you need to be able to send a value to processing so processing can actually read that value. The arduino code is down at the bottom of that code commented out. The arduino code is for a digital sensor but if you combine that with the Ping code you referred to and mix those two together you should be able to get what you want. You just have to tweak it the way you want it. To get Processing to print the values you need a

    println(PingValue); // you place the name of your variable in the parenthesis.

    Hope that information helps.

Sign In or Register to comment.