Hello
I'm trying my first Bela project - I want to use it in an exhibit but have hit a snag that I can't solve by any method. Any advice would be gratefully recieved! I can see lots of pointers to solutions in earlier posts but none that exactly demonstrate how to do this very simple thing:

I'm running a pd patch on Bela and want to send a list of numbers to an Arduino. What I really want to do is send direct commands via IC2, from inside the pd patch, to my servo boards - after trying for a few hours and hitting a dead end with that, I reverted to trying other methods i.e. putting an Arduino between the Bela and my boards. But I've come unstuck with that too. I really don't mind doing some number crunching / data crunching when the messages arrive - but I can't get Bela to send messages to the Arduino by any method. i.e. I couldn't find any lead for an IC2 external that works in Bela; I couldn't get Bela to recognise a Leonardo board as a USB midi device; couldn't get Serial to work. Last night, in a last-ditch attempt to get things working, I tried making direct connections between all the digital outs of the Bela and all the digital ins of the Arduino. This might be a fix (and it does make readable numbers) but it's messy. I'm sure there's a better one, especially as there's an IC2 port on the Bela board.
Thanks!
Sarah

    SarahA ; I couldn't get Bela to recognise a Leonardo board as a USB midi device

    this would be the easiest option as it won't require any C++ coding. Is the Leonardo showing up on your computer as a USB MIDI device? Once you plug it into Bela via USB, run the following command in the console at the bottom of the IDE: amidi -l . What do you get?

    4 days later

    Hello - thanks for this. Yes - if I switch things on on the right order I can get the Bela to see the Leonardo. The piece of info I was missing was the command that tells me which hw to use for which device. So thanks for letting me know that.

    Meanwhile, I've found some old pic code in C for IC2 send and receive functions. If I make a C external, can I address the IC2 port from within PureData? If so, I mgiht experiment with adapting this code. Ideally, I would like o be able to talk directly to external control boards from PureData on the Bela, without going via an Arduino. I've made externals in Max before and am assuming it's a similar process (i.e. find the template and adapt to suit your code, ins and outs).
    Thanks!
    Sarah

    There once was a better-i2c development branch I started in 2017 which allowed - among other things - to send and receive I2c messages from within Pd. I rebased it twice already to bring it up to speed with the rest of the Bela core. Following your request, it's time for the 2022 edition of better-i2c-rebased: better-i2c-rebased-2022.

    If you update your board to this branch (following the instructions here) you can then open the example PureData/i2c to write/read I2c messages from within Pd.

    As an aside, there exists at least one Pd external that allows to do I2C I/O. However, like most of Pd core and external, this performed I/O from within the audio thread, which is bad practice when dealing with real-time processing.

    Thanks! This is something I'd really like to sort out over the next week or so as it would be wonderful to be able to address servos directly from PD on the Bela (it would mean I could remove the laptop from many of my musical automata projects). I'll try the new branch - thanks for the tip.

    The useful PIC C code and tutorial I thought I could start from is here: https://www.robot-electronics.co.uk/i2c-tutorial

    Thanks again

    Sarah