[PD] problem in getting inputs from HC_SRO4

Alexandros Drymonitis adrcki at gmail.com
Tue Oct 7 11:04:54 CEST 2014


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 at 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 at lists.iem.at mailing list
> UNSUBSCRIBE and account-management ->
> http://lists.puredata.info/listinfo/pd-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20141007/bddc26a3/attachment.html>
-------------- next part --------------
#N canvas 392 99 518 261 10;
#X msg 76 102 close;
#X obj 83 62 hradio 15 1 0 16 empty empty empty 0 -8 0 10 -262144 -1
-1 0;
#X msg 83 80 open \$1;
#X msg 83 41 0;
#X obj 82 21 loadbang;
#N canvas 419 284 450 300 set 0;
#X obj 79 61 inlet;
#X msg 80 87 set \$1;
#X obj 81 116 outlet;
#X connect 0 0 1 0;
#X connect 1 0 2 0;
#X restore 26 62 pd set;
#X text 156 31 change this so that it matches the number of the COM
port you select in the Arduino software \, in Tools->Serial_port;
#X floatatom 125 169 5 0 0 0 - - -, f 5;
#X obj 125 145 comport;
#X connect 0 0 8 0;
#X connect 1 0 2 0;
#X connect 1 0 5 0;
#X connect 2 0 8 0;
#X connect 3 0 1 0;
#X connect 4 0 3 0;
#X connect 5 0 3 0;
#X connect 8 0 7 0;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ultrasound1.ino
Type: application/octet-stream
Size: 683 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20141007/bddc26a3/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: unltrasound2.ino
Type: application/octet-stream
Size: 940 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20141007/bddc26a3/attachment-0001.obj>
-------------- next part --------------
#N canvas 392 99 557 479 10;
#X msg 76 102 close;
#X obj 83 62 hradio 15 1 0 16 empty empty empty 0 -8 0 10 -262144 -1
-1 0;
#X msg 83 80 open \$1;
#X msg 83 41 0;
#X obj 82 21 loadbang;
#N canvas 419 284 450 300 set 0;
#X obj 79 61 inlet;
#X msg 80 87 set \$1;
#X obj 81 116 outlet;
#X connect 0 0 1 0;
#X connect 1 0 2 0;
#X restore 26 62 pd set;
#X text 156 31 change this so that it matches the number of the COM
port you select in the Arduino software \, in Tools->Serial_port;
#X obj 83 127 comport;
#X obj 83 152 select 192;
#X obj 140 276 spigot;
#X msg 152 338 0;
#X msg 83 201 1;
#X obj 102 338 spigot;
#X msg 122 201 0;
#X obj 83 176 t b b b;
#X obj 83 223 t f f;
#X obj 102 306 repack 2;
#X obj 102 360 unpack;
#X obj 102 382 t f b;
#X obj 135 401 * 128;
#X obj 102 418 +;
#X floatatom 102 440 5 0 0 0 - - -, f 5;
#X connect 0 0 7 0;
#X connect 1 0 2 0;
#X connect 1 0 5 0;
#X connect 2 0 7 0;
#X connect 3 0 1 0;
#X connect 4 0 3 0;
#X connect 5 0 3 0;
#X connect 7 0 8 0;
#X connect 8 0 14 0;
#X connect 8 1 9 0;
#X connect 9 0 16 0;
#X connect 10 0 9 1;
#X connect 11 0 15 0;
#X connect 12 0 17 0;
#X connect 13 0 12 1;
#X connect 14 0 11 0;
#X connect 14 1 16 0;
#X connect 14 2 13 0;
#X connect 15 0 12 1;
#X connect 15 1 9 1;
#X connect 16 0 12 0;
#X connect 17 0 18 0;
#X connect 17 1 19 0;
#X connect 18 0 20 0;
#X connect 18 1 10 0;
#X connect 19 0 20 1;
#X connect 20 0 21 0;


More information about the Pd-list mailing list