Can you send me your render.cpp ? giulio @ bela.io
Also, what version of Bela are you running?
Can you send me your render.cpp ? giulio @ bela.io
Also, what version of Bela are you running?
you have a
return true;
at the eight line of setup()
. This means that all the remainder of the function, where libpd
is setup and initialized is not executed. Therefore you are basically running the project without libpd
. I guess I should have specified that when describing the operations needed to achieve you result.
Remove that line and everything should work fine. Leave - however - the return true;
line at the very end of setup()
.
giuliomoro Never mind, I see the one I need to get rid of, the one I keep is on line 350
giuliomoro I've removedf the return true; on the 13th line of setup and now when I click run project I get this error:
right, that's because of the duplicated scope.setup()
lines. Remove the scope.setup(2, 44100)
from the fourth line of setup()
. Also, remove these lines from the top of render()
:
// Logging to the scope the pulse inputs and the distance
scope.log(digitalRead(context, n, P8_08), distance/100);
giuliomoro Thanks, still not getting audio or printed messages in the console
giuliomoro Nevermind, I had the wrong object name in Pd, getting it printed in the console now thanks for all your help - I'll give you a buzz if I need anymore help. Is there a donate function on the Bela website?
wow! no donate function yet, but I guess you can buy some expedited shipping if you are so inclined ! https://shop.bela.io/expedited-shipping
giuliomoro Haha, cheers I'm going to have a crack at implementing a second sensor and Pd object for it, thanks for giving me confidence with C++
good luck, let us know if you are stuck somewhere
giuliomoro Hiya, back again
I've attached two sensors now, with the second sensor attached to:
GND: P08_01 Ground
ECHO: P08_10
TRIG: P08_09
VCC: The pin next to (horizontally) P09_07
I've duplicated the variables at the top of the C++ file:
and made the duplicates and changes to the setup:
and duplicated the render part:
Here is my new Pd patch:
but as you can see, the console is printing the same number for both sensors. I get the feeling I've done something wrong with the render part...
You also need two separate PulseIn
objects.
Just now you are initializing the same object twice, with the second call to init()
probably overriding the first one, so you currently are only monitoring the second sensor.
giuliomoro Got it, thanks, I overlooked that. Now its working but the console is updating every 1 second or so, instead of the constant stream of data like it was before, any way to fix that?
giuliomoro Ah, its not actually, its just scrolling up the window and not staying at the bottom of the console window. Interesting..
That may be due to the zoom of the browser tab containing your IDE window not being 100%.
giuliomoro Yep I zoomed out for one of the screenshots haha
https://github.com/BelaPlatform/Bela/issues/275
Or maybe try to clear the console manually (with the button or cmd-k or ctrl-k).
I have a full PD solution for this if you're interested
https://github.com/5un/bela-ultrasonic-distance-pd
(Connection is all like in Bela's official c++ example)