I am quite a beginer and am trying to use ultrasound sensor with pure data.
Can numbers from Serial.print() and Serial.println () read from an ultrasound sensor HC SR04 read in a serial monitor be read in puredata.
I am using pduino o.5 abstraction to work in puredata
please suggest
-
Serial.print and println functions plotted in pd
-
The sensor you're using utilizes a built-in function of the Ardiuno language, pulseIn(), to measure distance. In order to use it with [pduino] you'll need to translate the internal code of this function to a Pd patch. It's a very usual mistake people make with pduino and this sensor.
You can try using my abstraction [serial_print] which works nicely with Arduino's Serial.print() function. You can get it here https://github.com/alexdrymonitis/Arduino_PdNote that in order to work you'll need to do something like this in the Arduino sketch:
Serial.print("distance "); // this is a tag for the distance data // note the space at the end of the string, it is important so that the [serial_print] abstraction // knows that the tag data has finished Serial.println(distance); // here distance is a variable holding the output of the pulseIn() function returned in cm
Then in Pd do this:
[comport 0 9600] | [serial_print] | / | / [send] [receive distance] | [0\ <- this is a number atom
This should work. Check the Arduino sketches that come with the abstraction.