Arduino ultrasonic sensor serial to max
Hey.
I am newbie to max and arduino.
I am going to play some soundfiles in an art gallery.
I need to start a soundfile in max with an SR04 ultrasonic sensor. I want to start the soundfile when the sensor is measuring a certain distance ( eks: 90 cm).
I think I have to use the serial-port using the serial port to send data to max 7??
Can anybody help me with a patch for max and a code for arduino?
Helge
Hi
there are three challenges for you to address: getting control (range) data into Arduino, translating into serial data (simple!), then receiving and translating it in Max. Have you worked out how to get the range finder working in Arduino?
Passing serial data to Max?
http://playground.arduino.cc/Interfacing/MaxMSP (avoiding Maxuino, for the moment)
Happy hunting!
:)
1. make the correct circuit for the HC-SR04, and read the data in Arduino
https://microcontrollerelectronics.com/distance-sensing/
2. if you only need to sense distance, then delete each of the "Serial.print/ln" lines in the above code example in this reply
3. replace those lines with "Serial.write(cm);" - no quotes
4. In Max, make a [serial a 9600 @autoopen 0] object; send it a (print) message, with your Arduino connected, but Arduino software CLOSED. The Max debug window will display a list of connected devices - change the "a" in [serial a 9600 @autoopen 0] to the letter that represents YOUR Arduino. Send it the (open x) message, where x is your Arduino port
5. connect a [metro 100] to the left inlet of [serial] and turn it on
6. I'll get back to you when you've done this much . . . . but I think all you need from the [serial] object output is:
[serial] --> [itoa] --> [fromsymbol]
Tada!!
Hi Brendan, I did what you suggested but it doesn't work, no data is coming in. Perhaps the USB serial is not good? Thank you
you should post your aruino code and max patch,
including infos about arduino board used, OS and max version.
one can't guess what along that path is done wrong
Thanks everyone, I've created a new topic with more info
https://cycling74.com/forums/58-sensors-hcsr04-from-arduino-to-max-for-installation