who can help me, I needed to have 16 switches and when 8 switches are closed, a yellow led will turn on, when 12 switches are closed, the red led will turn on and when all the switches are closed, another red led will turn on.
Using the CD74HC4067 multiplexer with one arduino Seeduino Xiao ? or outher ?
Please see Uncategorized - Arduino Forum why you should not post in "Uncategoried". Your topic has been moved to a more suitable location on the forum.
You can use a Mega if you not stuck with the Xiao . You can use I2C or SPI port expanders (MCP23008/MCP23017 or MCP23S08/MCP23S17); you can use a 74HC165 or you can use the 74HC4067. So many options.
Start by generating a schematic as to how you want to build it and then write some preliminary code. Without knowing what is there this "Code" is as good as anything we can do at this point. At this point without knowing what is there code cannot be written. This is like telling you to go see my friend, with no more information.
The usual design for a system such as you are designing is to have a totally separate switch that tells the program to "read" the switch settings right now. Otherwise you begin to have all kinds of logic problems when people set one switch and later turn it back off, etc.
A microcontroller can react much faster than a human can move switches - a microcontroller would be perfectly capable of keeping the LEDs updated from the current state of the switches.
Also if it were done purely in hardware - no code.