Go Down

Topic: reading multiple SPDT (On-Off-On) switches (Read 685 times) previous topic - next topic


How am I suppose to know that there is a mistake in the datasheet? Stupid me...

Now I know there is a mistake in the datasheet, things are obvious again.

I use the led's in a different manner. If the function is in automatic mode, the led is solid. If any function is in manual (on or off) mode, the led flashes. So, the switches controls the function and the software sets the led. Therefor separate pins. PCF8575 come cheap.



Sep 25, 2020, 12:01 pm Last Edit: Sep 25, 2020, 12:05 pm by RogMoe
Me again ;-)

I found these really nice switches with built-in bi-color led's (red/green).

What's the best way to control the led's, in such manner that I have the option to turn them BOTH off using as few as possible pins?

If the controlpin is not high or low, what happens to the leds?
or should I change the pinmode to INPUT in the loop?

or should I go with the second option, using two control pins? (last picture)


Well, the first option might allow you to illuminate either or neither (when the pin is set to INPUT) LED, but it works as a voltage divider - the LED voltage is limited to half the supply voltage - 2.5 V if using a 5 V supply and this may not illuminate the green LED properly, not at all if you were using a 3.3 V supply.  And of course, it wastes current.


Sep 25, 2020, 06:00 pm Last Edit: Sep 25, 2020, 06:07 pm by PaulRB
R4 and R5 don't have to be equal, I guess. You could make R5 slightly lower to ensure the green led gets enough voltage?

But as Paul__B already mentioned, you cannot do that with pcf chips. They don't have a true HIGH output state, only a weak pullup.

Maybe a mcp23017 instead? That has a true HIGH output state, I think.


yes, I moved to MCP23017 wich is basically the same IC. Have a few of those lying around somewhere. Easier to control too. I'll go with the second option anyway. Using two pins to control a bi-color led is okay I guess and makes coding a bit easier.


Go Up