I have a working project with pure data and 4 distance sensors via Arduino board. I tought I'd port to pure data and on Bela so I don't need a computer in the exhibition but didn't know it would be such a pain. I didn't know it would be impossible to set any pure data parameter in Bela IDE and so on. Anyway.
I thought I'd start first checking the example script here: https://learn.bela.io/tutorials/pure-data/sensors/distance-sensor/
Unfortunately the distance is jumping everywhere. It starts with 38cm when a large surface is on the sensor (very near), not 0cm, not 1cm or else, and then by gently moving the flat surface away, the distance jumps everywhere and is abs. not accurate making it impossible to use.
Needless to say, I’ve got the voltage divider in place, all is connected correctly etc.
Distance(cm):: 281.531
Distance(cm):: 43.0234
Distance(cm):: 41.4594
Distance(cm):: 41.4594
Distance(cm):: 38.3314
Distance(cm):: 39.8954
Distance(cm):: 38.7224
Distance(cm):: 37.5495
Distance(cm):: 37.5495
Distance(cm):: 38.3314
Distance(cm):: 37.9405
Distance(cm):: 37.1585
Distance(cm):: 36.7675
Distance(cm):: 36.7675
Distance(cm):: 36.7675
Distance(cm):: 37.5495
Distance(cm):: 37.1585
Distance(cm):: 37.9405
Distance(cm):: 42.2414
Distance(cm):: 44.1964
Distance(cm):: 46.9334
Distance(cm):: 281.14
Distance(cm):: 281.14
Distance(cm):: 281.922
Distance(cm):: 281.14
Distance(cm):: 282.313
Distance(cm):: 281.14
Distance(cm):: 281.531
Distance(cm):: 282.313
Distance(cm):: 282.313
Distance(cm):: 281.14
Distance(cm):: 282.313
Distance(cm):: 80.9501
Distance(cm):: 82.514
Distance(cm):: 74.6941
Distance(cm):: 76.6491
Distance(cm):: 72.3481
Distance(cm):: 71.9571
Distance(cm):: 71.9571
Distance(cm):: 70.7841
Distance(cm):: 75.0851
Distance(cm):: 75.4761
Distance(cm):: 75.8671
Distance(cm):: 76.2581
Distance(cm):: 75.8671
Distance(cm):: 76.2581
Distance(cm):: 76.6491
Distance(cm):: 281.922
Distance(cm):: 280.749
Distance(cm):: 71.5661
Distance(cm):: 282.704
Distance(cm):: 63.3552
Distance(cm):: 62.9642
Distance(cm):: 62.9642
Distance(cm):: 63.7462
Distance(cm):: 61.4002
Distance(cm):: 59.8363
Distance(cm):: 60.2273
Distance(cm):: 60.2273
Distance(cm):: 59.4453
Distance(cm):: 59.4453
Distance(cm):: 59.4453
Distance(cm):: 58.6633
Distance(cm):: 58.2723
Distance(cm):: 59.0543
With Arduino & pure data I'm able to measure up to 200cm for my project (even up to 400cm). Here after 70cm (which are actually 70-38 as the measure starts at 38!) it jumps to 280...
My biggest problem is that I can't test in pure data directly changing parameters to understand why this code is not working.
I'm searching the forum and can't find anyone having it simply running, with a post where I see the example is working fine. I see noobies question but not the thing working fine.
I even checked this: https://github.com/5un/bela-ultrasonic-distance-pd but I'm at this stage still struggling with the pinout on Bela and loosing so much time as a user figuring for instance where is P9_07 and P8_01 on Bela while looking at https://learn.bela.io/pin-diagram/.
So 2 questions:
1- Did anyone had the sensor example working fine?
2- Is there a way to work in pure data directly when Bela is connected to the computer via USB (means powered) with the sensors connected to it?