Maxuino to control many leds with Arduino

R_Gol's icon

Hi there,
I have a project involving 60 leds and a sequence of around 10 minutes long.
I was thinking to make the sequence in Max MSP and control the LED on/off states with maxuino.

here is an example of the first 60 seconds (0-59) for leds 8 to 59 :
what is my best option for create those sequences and controlling the Arduino leds? shall I use Coll ? counter? maybe there is an option to convert excel to control those data?
What would you suggest me doing?
Many thanks!

first 60 sec of 60 led pattern.pdf
application/pdf 77.62 KB

R_Gol's icon

each bit represented a led state at a given interval (assuming intervals are all 1000 millisecond)
is it possible to output the element index 0 from both line at the same time? kind of reading Coll from top to bottom left to right

Peter Ostry's icon

The [coll] message 'nth ...' is your friend. It can recall any position of any line. Look at coll's help pages and inspect the supported messages in coll's reference. For the recall process you may need a counter or combined counters, probably with another coll, whatever your recall pattern requires.

Regarding Excel: Yes, a spreadsheet can help. Export as text, prepare the data in a smart text editor like BBEdit (if you are on a Mac) and paste the text into coll's editor window. [coll] can also read text files, which is often preferable.

R_Gol's icon

The solution I have found for the moment using Coll is to have a different Coll for each LED
in each Coll line n represent the first sequence of 20 frames (in each second either 0 or 1)
then the second line will represent the next 20 frame etc.
then I'm using a zl.lookup and a counter to run through the 20 frames and either sending 1 or 0 to the digitalWrite object of maxuino.

I was wondering if I can represent in a single Coll all of the leds states?

how can I extract in a single bang output of 60 led state to 60 different 'digitalWrite' object?

Max Patch
Copy patch and select New From Clipboard in Max.

Source Audio's icon

It depends on your programming way.

If you would look at each led similar to note
messages in midi world, you simply record or program
the events that control 60 LEDs in given time.
The challenge is to find a way to deal with chasing the state of all LEDs
if one restarts the sequence at any other time than the very beginning.

In theory you could make midi sequence, assign 60 notes to LED numbers,
and use velocity 1 or 0 for LED On/Off states.
Instead of sending midi you route note numbers to Arduino DigitalOutputs.

It is not difficult to play a sequence, but to program it.
Using midi in pianoroll and real time display would be easy way to do so...
-------
If you prefer list , than I would use list with 60 LED states,
route each unpacked event through change object to avoid resending data.
You could use jit.cellblock to program and play the sequence,
but also to dump from cellblock into coll for only playback.

Check listfunnel object, to easily route list events to Arduino
without need to unpack 60 list items.

R_Gol's icon

when you say list - what object are you talking about? Coll?

R_Gol's icon

list funnel is indeed very useful!

Max Patch
Copy patch and select New From Clipboard in Max.

R_Gol's icon

any idea why I'm getting those error messages?

Source Audio's icon

I don't use maxuino, and reject any premade stuff.
It could be that it supports only limited number of digital outputs.
Or is it that you use pinMode in wrong way ?
pinMode in Arduino is either INPUT, OUTPUT or INPUT_PULLUP
but I have no idea what that maxuino is doing at all...
From the patch I see you define pinMode each time when a value is sent , why ?
Maybe the messages are too fast and the whole system is inefficient.

list - I mean 60 values for 60 LEDs in one list, no matter if in coll,
text or any other max object

Rob Ramirez's icon

reiterating the sentiment that moving away from maxuino for non-beginner projects is advisable. ie creating your own abstractions specific to your project around the serial object in order to minimize the data sent.