Control 16 inputs switch to show the 3 level leds

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 ?

thanks your support .

Best regards,

Carlos Simoes

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.

Thank you your replay , is possible help me the code ?

thanks

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 12C MCP23017 port expander has 16 GPIO pins. There are internal pullup resistors that can be enabled on each pin. There is a library thst makes using the MCP32017 pretty easy. >> GitHub - adafruit/Adafruit-MCP23017-Arduino-Library: Arduino Library for Adafruit MCP23017

Is that any 8 switches, or a specific set of 8 switches?
Is it exactly 8, or at least 8?

Again, any 12 switches, or a specific set of 12 switches?
Does the yellow LED turn off?

Do the other LEDs turn off?

1 Like

You may need eventually to count the number of 1s in an integer.

Fortunately that part is a popular problem with many various solutions, for example

HTH

a7

Hello csimoes08

Take the IPO model to get started:

INPUT : recognise keys==pressed
PROCESSING: count keys==pressed
OUTPUT: digitalWrite(LEDred,count==4);
        digitalWrite(LEDgreen,count==8);
        digitalWrite(LEDblue,count==12);

Have a nice day and enjoy coding in C++.

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.

Eh??

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.

Is that any 8 switches, or a specific set of 8 switches?
Is it exactly 8, or at least 8?

is specific input from 1 to 8 and led on yellow and when plus switch input 9 to 12 led yellow off and on led red .

Thank you your support

Pardon?

You mean the Yellow LED is on if & only if all LEDs 1-8 are on AND all other LEDs are off?

The 1st red LED is on if & only if all LEDs 1-8 are on AND 9-12 are on AND the rest are off?

The other red LED is on if & only if all LEDs are on?

So you could do that with just some logic gates - no microcontroller required!

Here you go:

1 Like

Great idea.

Use a 4k EEPROM simply.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.