Go Down

Topic: Is there a way to reduce resistor count in this circuit? (Read 888 times) previous topic - next topic

MAS3

Why polling dipswitches ?
Aren't they always the same unless changed during power off ?
Typically dipswitches are set before you power up.
If that's indeed the case, you do not need to poll those during your program.
Just read them once during power up /setup.
You can even use a single pin to select the dipswitches and use the other pins for whatever need you have after reading those switches.

Have a look at "blink without delay".
Did you connect the grounds ?
Je kunt hier ook in het Nederlands terecht: http://arduino.cc/forum/index.php/board,77.0.html

dc42


Thanks for the idea. I originally had the pushbutton on its own pin (PB2) so I could use the hardware interrupt on it, but since I have to poll the pins for the DIP switches anyway I think I can make it work.


It's quite possible to use multiplexed input pins like this and still to have an interrupt generated when the system is idle and a particular button is pressed. I've recently done that in one of my designs, where I wanted to wake the system from sleep mode when a particular button is pressed (because that button doubles as the power button).
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

MarkT



Thanks for the idea. I originally had the pushbutton on its own pin (PB2) so I could use the hardware interrupt on it, but since I have to poll the pins for the DIP switches anyway I think I can make it work.


It's quite possible to use multiplexed input pins like this and still to have an interrupt generated when the system is idle and a particular button is pressed. I've recently done that in one of my designs, where I wanted to wake the system from sleep mode when a particular button is pressed (because that button doubles as the power button).


Doing 4 switches at a time like this rather than all 8 will reduce the noise problem greatly.  A common 1k8 pull down, then
4 switched pull-ups (1k, 1k8, 3k9, 8k2) for a pin would give 16 distinct voltage levels with reasonable spread, and you'd need
2 pins, 10 resistors in total.
[ I won't respond to messages, use the forum please ]

Henry_Best


Go Up