Arduino (FLORA) accelerometer/gyroscope data translated to Max/MSP: HELP!!
Hello community, I'm working on an audio installation using an Arduino accelerometer/gyroscope data read into a Arduino FLORA board which is then sent into Max/MSP. I'm very new to Max and even after going through tutorials and example programs they don't exactly point me in the right direction into getting the coordinate data from the serial info of the Arduino into a Max patch I can then manipulate the data with. Does someone mind helping me figure this out?
Hi:
1. in Arduino are you seeing the expected data/values in the Serial Monitor window?
2. look for the lines in the Arduino code that read "Serial.print(ax)", "Serial.write(gy)" or similar. These are the lines that send the sensor values to the USB-serial port.
2a. CLOSE THE ARDUINO SERIAL MONITOR
3. The [serial] object in Max reads these values, but you will need to do a bit or work/research to get it to suit YOUR specific needs, not all sensors are the same!! The more values and data that the code is outputting, the more parsing (data juggling) you'll have to do in Max.
4. read these links:
https://cycling74.com/forums/communicate-arduino-and-max-with-simple-serial
https://cycling74.com/search-results/#gsc.tab=0&gsc.q=ARDUINO%20ACCELEROMETER&gsc.sort=
Brendan
Thanks for the reply Brendan,
Yes I am getting the accelerometer/gyroscope/magnetometer data on the Arduino side. The "serial.write" functions are spitting out the x,y,z translations of each sensor. The Arduino app and serial monitor are closed whenever I test the Max/MSP side.
Exactly, i've been working on the research to unpack/parse the data into something I can work with in Max. But, as I am fairly new to Max this is proving difficult. I'm putting this on the table in this forum just incase anyone that has already dealt with an issue similar or an expert in Max/MSP will be able to point me on the right path to succeed.
Hi
just post a code snippet here that covers all the Serial.write values, and we'll take it from there.
Brendan
As first You can simplify the data sent to serial.
Instead of all that Serial.Print("Accel X: "); Serial.Print((int)lsm.accelData.x); Serial.Print("Y: ") ..............
You could just prepend one Letter for Accel, one for Mag, Gyro etc
One line would look like : Serial.Print("A ");Serial.Print((int)lsm.accelData.x); Serial.print(" ");
Serial.Print((int)lsm.accelData.y); Serial.print(" "); Serial.Println((int)lsm.accelData.z);
In max (after usual ASCII conversion) just insert route A, followed by unpack 0 0 0 , and You have the 3 Values out.
For Maag, Gyro and Temp the same, just temp needs no unpack, having only one value.
thats arduino basic.
Thanks for the reply Source Audio, this has gotten Max spitting out some numbers now and I believe separating each 3 values to each Accel, Mag and Gyro set. Are these the simplest form of malleable numbers? I intend to use this live data to combine with ICST's ambisonic library to rotate an audio track.
The sensor that You are using is very flexible, one can adjust the range for each sensor.
I am not sure if the output range remains the same, (in terms of output values)
but You can scale the data in both Arduino code, or in max, which would be better option.
It just matters to get the output of sensor to work within needed values.
So I would first check what ICST’s ambisonic library needs to rotate Audio the way You want it,
and then scale, combine or whatever the 3 Values coming from sensor.
2 Values for panning arround and one for distance from the center I guess.
I don't know how usable the data from your sensors are. I realised that in most cases, I ended up not needing much precision. If it is your case, you may want to look at USB MIDI Flora, with TeeOnArdu. I personally prefer using MIDI in MAX when I don't need much precision. I had less issues.