Removing first number from a value when sorting arduno sensor data over serial.
Hi there,
I'm relatively new to Max and have started a project where I have set up ultrasonic sensors with an arduino to transmit distance measurements into max. I've hit a road block which seems simple but can't figure it out for the life of me.
I've managed to get my data streaming properly, convert it from ASCII to unicode, split the data up according to its corresponding sensor (I'm using three sensors currently).
The values I am getting have the sensor number followed by the sensor measurement.
e.g the value 1354 means this value is from sensor 1 and has a measurement of 354cm.
All I want to do is remove the sensor/first number "1" from the number value so I can then use the measurement data separately and accurately.
It feels like a stupid question but is there a simple way to do this?
I've tried using multiple zl objects and in my research the only thing I can really find is people trying to use regex to do it but that is a bit over my head (although if that is the best way to do it happy to learn).
Currently I am using three sensors (0, 1 and 2) and the sensor number is always the first digit. I am hoping to scale this up to using 10 sensors (0-9). I guess using any more than that would go into double digits and complicate things? I can change my arduino code to format the data differently if that makes it easier to sort (e.g adding an = between the sensor number and measurement or something).
First time posting so let me know if I've missed out any key info.
I've included a screenshot of the data streaming as I'm guessing if you open the patch without my arduino you wont get any values.
My current patch is below. Any tips of optimizing the other sections are welcome too!
Thanks for your time.

There are different options. One of them could be to add a space between the sensor ID# and the measurement value directly in the Arduino code. For instance (sensor 1, value 354) :
Serial.print(1);Serial.print(" ");Serial.println(354);
This will give in Max 1 354. You can then use [route] to route the corresponding value :

Another one, if you want to keep the Arduino code untouched:

(but if measurement is >999 it doesn't work)
Thank you! Both ways work well and both ways look like they work with >10 sensors!
The split options works fine as I can set max range of the sensor to read <999 and return 0 if max set distant is reached.
It also sparked another idea a way to do it. Adding a space gave the each sensor number and measurement number its own index in the list and I can now call them up one by one with zl.math too.
Appreciate the help and inspiration - Thanks again!

you are beter off to prepend id to each sensor,
which avoids sending of the whole list containing all sensor values,
even if only 1 sensor changed state.
Which is very sluggish option for several sensors.
Sluggish, I don't know, but certainly not optimal ;-)
Another proposal, with the initial un-changed code (i.e. without space : Serial.print(1);Serial.println(354); for instance) :
