Hi, I'm fairly new to arduino. I'm working on a PD patch that gets data out of an accelerometer (a MMA8451). It works fine, but I'd like to know something in order to improve things. The arduino code is very simple, it outputs data this way :
So I get a stream of ascii values in Pure Data. I use 'a', 'b' and 'c' as arbitrary values in order to separate the x, y and z values in my patch. Just to convert my data into numeric values, I had to do this ugly piece of patch :
There might be a more elegant way to do it, but my question is the following : is there a way to get numeric values directly out of arduino, so I get them directly with comport? A kind of list I would just have to unpack?
-
Arduino - Data Type
-
The
Serial.write()
function writes raw bytes to the serial line. You can build your own protocol to receive and parse these values in Pd.
I've made two vanilla abstractions, one that works with Arduino'sSerial.print()
and one that works withSerial.write()
. You can get them here https://github.com/alexdrymonitis/Arduino_Pd
There's one Arduino sketch for each abstraction explaining how to write your code in order for it to work with the corresponding abstraction.