[PD] Retrieving data directly into PD from HC-SR04 sensors connected to Arduino

Pierre Massat pimassat at gmail.com
Tue Apr 24 16:49:22 CEST 2012

Are you using this code :

Apparently Ultrasound sensors need to use a single pin as both input and
output (to send a pulse and to receive the echo). Unfortunately i don't
think Firmata can do that (it should be possible but I suspect there would
be some latency when switching from input to ouput back and forth -
somebody confirm this??).

If you only need these 4 sensors, you can adapt the example code for
ultrasound sensors to output the data, and read it using [comport] in Pd.
This object is at the core of Pduino.

(You shouldn't see anything in Pd console when using Pduino, except
information about the current connection and the device.)

2012/4/24 Emin Durak <e10durak at gmail.com>

> Hej Pierre, thanks again.
> It works perfectly at Arduino Serial Monitor; all 4 sensors that are
> connected to.
> Should I only upload the firmata library and not write any code besides
> for the sensors you mean? I have uploaded the whole StandardFirmata.ino
> example file. But you mean only *firmata library* +* sensors library*(there is one) +
> *sensors code* will be sufficient?
> I would say let's simplify it. Let's have 4 different channels of music
> (sound files) w're playing. We wanna change the frequency of them *by the
> data gathered from 4 sensors. *Will need to put +5000 to the number we
> get for us to actually hear the frequency, but let's say. Or I'm fine to
> just "see" the analog data on PD as well. How would we do that? I send you
> the screenshots of how I adjusted PD... Ah, should I be seeing the numbers
> from sensors at the main PD window?? I get here this:
>  [image: Inline image 1]
> On Tue, Apr 24, 2012 at 4:12 PM, Pierre Massat <pimassat at gmail.com> wrote:
>> First you need to make sure the electronic part is working fine (using
>> Arduino IDE's serial monitor).
>> Then upload Firmata. If your sensors need no special library you should
>> upload Firmata only.
>> Then open arduino-test.pd with your board plugged in. The first thing you
>> want to check in Pd is whether the right port is open. Choose a port, and
>> click on the "Version" or "Firmware" messages to see if Pd recognizes the
>> Arduino. If it does you should see a "Firmata something" below [pd device
>> info]. If nothing appears, change the port and try again.
>> Once you've made sure that the right port is open, use the pink matrix in
>> the upper right corner to open the pins your sensors are connected to. The
>> digital pins are from 2 to 13 if i'm not mistaken, the rest is analog.
>> Check "input" to open a digital pin for input, and "analog" to open an
>> analog pin for input.
>> Pierre
>> 2012/4/24 Emin Durak <e10durak at gmail.com>
>>> Hi Pierre,
>>> Thank you very much for your tips. Yes I have been trying but how would
>>> I configure the analog pins as analog inputs at Pduino? I'm trying with
>>> ultrasonic sensors to read data (which is not on/off). And have uploaded
>>> the StandardFirmata code besides my sensors reading code to Arduino. And
>>> testing on the arduino-test.pd sketch on PD. Ain't working :(
>>> Cheers...
>>> On Tue, Apr 24, 2012 at 9:22 AM, Pierre Massat <pimassat at gmail.com>wrote:
>>>> Do you use a special library in Arduino to get data from your sensors?
>>>> If not Firmata + Pduino should work just fine. Are you sure you opened the
>>>> right port in Pduino? Did you configure the analog pins your sensors are
>>>> connected to as analog inputs in Pduino?
>>>> If you're not familiar at all with Pduino I suggest you try it with
>>>> more simple stuff (like push buttons and pots).
>>>> Cheers,
>>>> Pierre.
>>>> 2012/4/24 Emin Durak <e10durak at gmail.com>
>>>>> Hello!
>>>>> I'm sorry this email will be probably too amateur but I just couldn't
>>>>> figure out for days how to retrieve data into PD from the sensors I connect
>>>>> to Arduino (HC-SR04 ultrasonic sensors). I have no problem viewing them on
>>>>> Serial Monitor of Arduino software by some libraries I found online, though
>>>>> processing them at PD seems a bit tricky. I have tried SimpleMessageSystem,
>>>>> Firmata and Pduino but couldn't really have managed in neither of them.
>>>>> All I want to do is changing different parameters (frequency,
>>>>> loop-time, volume etc.) of playing sounds from an existing library (just a
>>>>> folder with songs/sounds), thus play them *accordingly *to the data I
>>>>> gather from sensors (10 of them). Plus making relevant changes throughout
>>>>> *time*. Idea is that people dancing on a dance floor can affect the
>>>>> sequence of electronic music played, in a collective and sensual way. Me
>>>>> being only a starter at PD, also, doesn't help much either; but gotta do it
>>>>> for my graduation. Technically I can't really "create" music like that in
>>>>> this short time and it's not my interest; BUT I feel like *modifying*existing music shouldn't be a big deal. No?
>>>>> Any suggestions? Highly appreciated! Thank you all!!
>>>>> Emin
>>>>> _______________________________________________
>>>>> Pd-list at 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/20120424/2f429686/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 12304 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20120424/2f429686/attachment-0001.png>

More information about the Pd-list mailing list