How to create random color picker from pre-defined colors?

Marlou Kellenaers's icon

I want to create a random color picker from pre-defined colors.
The input should be for example 6 pre-defined colors: red, yellow, green, blue, purple and orange.
By clicking on the 'bang' the output should be one of those colors, randomly chosen.

How can I create this? I am new to this platform so I don't know how to start.
I hope you can help me.

Thank you in advance.

Francois Weber's icon

Hi Marlou,
Here is an example

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


Marlou Kellenaers's icon

Thank you francois, that is exactly what I need.

Marlou Kellenaers's icon

Hello,

I have the code you sent working right now.
However, I need 4 random color pickers in one Max MSP document.
If I do this right now with the same code, I can only have the same colors in every random color picker.
How do I ensure these color pickers are not connected and I can have different colors in each color picker? They are all turned on with a different bang.

Thank you