Can you create an array of PinButtons (from the Multibutton library)?

Hi all,

Apologies if I'm missing something massive here, but having tried a few iterations of this (getting no exceptions from Create but having nothing happen when I run the code) I wondered if I'm going about this all wrong/how best to go about it?

I'm trying to use the Multibutton library for double clicks and long clicks on a set of 7 buttons. They all work as intended when initialised like in the code example, however since the rest of my code gets more complex and I don't really want to have it written 7 times, I am looking for some way to use the PinButton function and its associated .isClick(s etc) in a loop.

The simplest way I imagine this working is to have an array of the buttons, so I can do

PinButton buttons(arrayofpins);

for (count = 0; count <= 7; count++){
if buttons[count].isClick{
*dosomething
}
}

Obviously this doesn't work, but even with more complex iterations (using PinButton separately on each array element, using PinButton on separate variables then assigning them to an array etc etc) I still can't get this to work as I'd hope. Any chance of some pointers please?

Apologies if I'm way off here - it's been half a lifetime since I last worked in C++!

Sorted my own problem - I tried every combination of 'above setup' 'in setup' 'with a data type' and 'without a data type' except one. So for posterity, the working code is:

PinButton2 buttonsarray[] = {PinButton2(1),PinButton2(2),PinButton2(3),PinButton2(4),PinButton2(5),PinButton2(6),PinButton2(7)};

With no data type for the array, placed above void setup()

Allows you to do buttonsarray[count].isClick and all other Multibutton commands in a for loop :slight_smile:

Hope that helps someone one day!