Hi I had been trying get distances as numbers from a ultrasound distance sensor HC_SRO4 from the echo pin . while trying to do that i am getting an error message in the console window and the number input attached to the echo pin through the route object is remaining plum at zero the error message that i am getting in the console window is as follows: UNKNOWN_INPUT_COMMAND: 0 28672 UNKNOWN_INPUT_COMMAND: 0 28672 UNKNOWN_INPUT_COMMAND: 0 28672 UNKNOWN_INPUT_COMMAND: 0 224 UNKNOWN_INPUT_COMMAND: 0 224 UNKNOWN_INPUT_COMMAND: 0 28672 UNKNOWN_INPUT_COMMAND: 0 28672 UNKNOWN_INPUT_COMMAND: 0 224 UNKNOWN_INPUT_COMMAND: 0 28672 UNKNOWN_INPUT_COMMAND: 0 224 UNKNOWN_INPUT_COMMAND: 0 224 UNKNOWN_INPUT_COMMAND: 0 224 please suggest how to get distances through the pd patch I am attaching the sketches please tell me whr i am getting wrong and what i need to change in the pduino patch to get a number inputs
thanks Sujay
You're trying to send both numbers and text as bytes (Serial.write transfers bytes to the serial port). Your sketch checks whether the value read from the sensor is within range and if not, it warns you with text, but to receive text you need to use Serial.print which transfers ASCII values. Then you'll have to assemble that text in Pd (I guess with [makefilename] or something, but have never tried it). If you wanna use Serial.write (which I think is the way to go), you shouldn't send text, but only values. I've written two versions of your sketch, one checks if the distance value is within range, and if not, it zeros that value, else leaves it intact and writes it to the serial port. The other version splits the byte to two, in case the value exceeds 255 (no idea what that range is), as Serial.write transfers bytes and if you get a value higher than 255 (a full byte), Serial.write won't be able to transfer that and your value will wrap back to zero.
Also, you were trying to use a custom Arduino sketch with Pduino, which works only with Firmata. I've changed the Pd patch as well (for both versions). Check it out and let me know if it works.
On Tue, Oct 7, 2014 at 11:29 AM, Sujay Mukherjee mukherjee.sujay@gmail.com wrote:
Hi I had been trying get distances as numbers from a ultrasound distance sensor HC_SRO4 from the echo pin . while trying to do that i am getting an error message in the console window and the number input attached to the echo pin through the route object is remaining plum at zero the error message that i am getting in the console window is as follows: UNKNOWN_INPUT_COMMAND: 0 28672 UNKNOWN_INPUT_COMMAND: 0 28672 UNKNOWN_INPUT_COMMAND: 0 28672 UNKNOWN_INPUT_COMMAND: 0 224 UNKNOWN_INPUT_COMMAND: 0 224 UNKNOWN_INPUT_COMMAND: 0 28672 UNKNOWN_INPUT_COMMAND: 0 28672 UNKNOWN_INPUT_COMMAND: 0 224 UNKNOWN_INPUT_COMMAND: 0 28672 UNKNOWN_INPUT_COMMAND: 0 224 UNKNOWN_INPUT_COMMAND: 0 224 UNKNOWN_INPUT_COMMAND: 0 224 please suggest how to get distances through the pd patch I am attaching the sketches please tell me whr i am getting wrong and what i need to change in the pduino patch to get a number inputs
thanks Sujay
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list