I'm trying to build a cockpit chair for my simrig and I want to use toggle switches to control whether a USB device has power. While that's easy enough, I also want to setup an arduino to play a sound effect whenever a switch is toggled on or off. I'm not at all sure how to wire this.
I have an arduino, a 9V 1A barrel jack wall wart, a breadboard, several SPST switches with LEDs, and a handful of TIP 120 transistors.
I was thinking splice into the positive wire for a USB cable, connect the powered end to the collector of the transistor, connect the device end to the emitter, and run a wire from the base to a slot on the breadboard. Beyond that, I'm stumped.
Any help? I'm mostly looking for wiring help now, programming help will come later, but is welcome now as well.
USB is 5V and the Arduino I/O pins are 5V so you can just directly wire the switched USB power into an input pin and read it high or low. Of course, the Arduino has to remain powered if you want to make a sound when the switch is turned-off.
It would be "good practice" to add a pull-down resistor (1K - 10K) on the input pin to make sure it's low when USB power is off, but that's not strictly necessary if there's a load being switched. (Whatever is being USB powered will pull-down the Arduino input when it's un-powered.)
So, for each switch, I would run another wire from the switch to a pin on the arduino, tell the arduino to read that pin, then have a wire from a different pin run to the gate (base) of the transistor to complete the circuit when the arduino powers that pin? Add to that the fancy programming mumbo jumbo to make the sound effect work?