Even though I am new to the Arduino platform, Im both fairly good at programming and electronics in general. Have a project to help a friend with a Halloween prop setup/mad scientist setup, Frankenstein control panel etc. He's wanting the following:
-Rocker switches (SPST) that play different WAVs when pushed one direction or another - possibly even a round robin playlist
-Standard push button switches that turn LEDs on and off
-Reed switch that again possibly play different sound effects when sticking in prop punch cards like an old analog computer
-Series of flashing LEDs
Thinking of using an Arduino MEGA for the large number of pinouts with a Music Maker shield.
-LEDs look pretty straightforward as Pinout commands
-Push buttons pretty much the same for turning on LED or playing a single sound file
For the rockers and reed switches, I'm thinking a push/pull 10k resistor in line with the switches and changing the value to 1 or 0 each time, and then performing an action when the value changes? Am I on the right track there? Thanks for any feedback.
There are optional internal pull-up resistors that can be enabled. Then you wire the switch to ground so when the switch is off the input is pulled-high and when it's on, the input is forced low.
With a double-throw rocker switch you can ground the common pin and use two input-pins. If the rocker has center-off, you have 3 possible "states".
For the LEDs, note that there are some current limits. The "absolute maximum" for an I/O pin is 40mA, with 20mA or less "recommended". And the combined total is 200mA. So if you need lots of LEDs on at once, or if you're driving high-power LEDs, you'll transistor or MOSFET drivers.
You could cut your I/O needs with a keypad to handle some of the inputs. Consider ancillary ICs like shift registers for input or output, or an I2C-controlled MCP23017, or similar, which has sixteen individually configurable digital I/O.
There are optional internal pull-up resistors that can be enabled. Then you wire the switch to ground so when the switch is off the input is pulled-high and when it's on, the input is forced low.
Thanks - hadn't known that. Interesting. Since it varies between 20-50pohms, how much wear and tear does that put on the mega chip over time, or is it negligible?
For the LEDs, note that there are some current limits. The "absolute maximum" for an I/O pin is 40mA, with 20mA or less "recommended". And the combined total is 200mA. So if you need lots of LEDs on at once, or if you're driving high-power LEDs, you'll transistor or MOSFET drivers.
In the case of a push button/reed switch, using Super Bright 10mm white LEDs, so 20ma per. Only turning on one-three at a time, so probably not going to be an issue - we'll see what happens at breadboard. Other than that, have a separate bank of about 10 LEDs flash on and off randomly each LED on a separate printout not tied to any switches at all - they are just background look-nice.
Also interesting. Had thought about ICs - its just such a nightmare these days with the supply chains issues, I almost feel like Forrest Gump - "you never know what you're gonna ge"t. Been waiting on a Raspberry Pi Zero W for 6 months now for another project - off-topic, but if Broadcom wants to be the chip supplier to every IoT device in the world, they need to step up their production game (sorry rant over).
I did something similar last year (but it was dragons) using a Wemos D1 Mini. I had six buttons that started a different "scene" all wired to A0. Each button had a different size resistor and A0 had a 1K resistor to ground. This way each button presented a different voltage on A0 which was easy to discriminate.
I only needed a single pair of wires on a button bus.