Hello, premise I'm an Arduino amateur at the beginning, I thank you in advance for reading my topic .
This is the deal: I want to measure the distance with 3 HCSR04, change the audio spectrum of an audio file inside MaxMsp(the changes depends on the 3 distances received from the 3 HCS04) and move 3 servos depending on the audio spectrum.
I figured out 2 situation, with and without Maxuino ???:
If I use Maxuino how can I implement the HCSR04 code in Firmata in order to receive the distance in Maxuino? Can I receive the 3 distances and move the 3 servos at the same time?
If I don't use Maxuino, how can I read the 3 distances from the 3 HCSR04 in MaxMsp ( then change the parameters of audio spectrum) and then send the positions for the 3 servos to Arduino IDE ?
I want to really thank you for your time and would be amazing to have an help from you .
If I use Maxuino how can I implement the HCSR04 code in Firmata in order to receive the distance in Maxuino?
You can't. Firmata makes the Arduino stupid. ALL of the commands need to be issued by the PC application. You will need to make the PC app do everything that the Arduino would normally do - trigger the pulse, enable the echo pin, time how long the echo take to return etc., strictly by polling. Which, obviously, isn't going to work.
Thanks a lot PaulS for your kind reply.
I thought also to copy the operations from the Arduino IDE to Maxuino like you mention, but the problem comes with the function pulseIn....bad way.
I take advantage of this opportunity to ask you something about the second way, without Maxuino: do you know a way to read 3 different parameters (the three distances from the sensors) into MaxMsp and then send another data (the servos positions) from Max to Arduino?
The signal flow would be something like this:
HCSR04 measurements ----> Arduino ----> Max, using the measurements to create the servos position (based upon the frequency spectrum of audio file) ----> Arduino ------> Servos
do you know a way to read 3 different parameters (the three distances from the sensors) into MaxMsp
Not a clue. I know how to make the Arduino send three different parameters, as text (Serial.print()) or as binary values (Serial.write()).
Making MaxMxp read the data is not an Arduino issue. You might get help in the Interfacing with Software on the PC part of the forum, or from the venerable Mr. Google.