low-to-high transition), an input value appears at QH, and the internal states are pushed one step "to the right", meaning that the second flipflop then contains the old value of the first, the third flipflop the old value of the second and so on. Now your microcontroller would start to send a clock signal (high,low,high,low,…) to the CLK input. Now, having pulled SH "high" again, the input values are stored in the flipflops. That way, you save yourself a lot of soldering work, and your circuit can look very clean and tidy. Yet another hint: if you need to go shopping for parts, buy so-called resistor networks for example, there's parts that contain 8 identical resistors that have one common pin (which you'd connect to ground here, and 8 individual pins. The actual resistor and capacitor values aren't critical – if you use a resistor value that's too small, you'll draw a lot of current with every button pressed, and if you choose a capacitor value too large, buttons will appear to take a long time until they are effectively pressed and released, but in general, something like 10kOhm and 10nF – 100nF, values abundant in most part boxes, should do well for human interaction. It's usually recommendable to connect a capacitor in parallel to the resistor, because that will counter so-called "bouncing". That way, when the button is pressed, the voltage at the input is "high", otherwise it's low. The idea is the following: When the SH pin is pulled low, the values at pins A-H are stored in the internal flipflops, so this is where you connect your switches/buttons that either connect the pin directly to supply voltage (if pressed, for example), or ground the pin throug a (largish) resistor: The picture is from the Texas Instruments SN74LV165A datasheet.
In the simplest case, this would simply be a parallel-to-serial-shift register, for example some variant of the 74xx165: The classical approach here is to use some kind of IO extender IC. But this solution is pretty neat and a bit out of the box, and deserves some evaluating.
I would definitely go for i2c IO expanders. Moreover, if you have long wires going to the console, you will probably need to buffer the signal to avoid spurious reads.Īll in all this works, requires not many components but is suboptimal at the least. And you get some error because you do not have SPDT push buttons, and you need to use the pull down. The ADC on the nano should be precise enough, but you need to check if it accepts rail to rail inputs. First of all, you need precise resistors, or you will get non monotonic behavior which is very bad. Since you have an eight bit converter, the routine will be pretty neat: uint_8t sw_status You can sample the analog voltage with the arduino ADC and then convert it back to a digital representation of the status. Where N is the number of switches, in this case 6. The output voltage depends on \$V_\$ and is:
the leftmost.Īs an example, if you press SW6, 3 and 2 the digital number is \$D=100110\$, which in decimal is 38. the rightmost bit, while SW6 is the MSB, i.e. If the button is pressed, we say it is 1, if it is not pressed we say it is 0. I will not dig in how this circuit works, refer to wikipedia for an explaination, what you want to know is that if we associate a digital number to the push button states, the output voltage is an analog representation of such number.
#Pull the pin challenge level 38 series#
Some good values you can start with are:īetter yet, use one \$100k\Omega\$ resistor for R and two of them in series for the 2R resistor. Simulate this circuit – Schematic created using CircuitLabĪll r should be small enough wrt to R to pull down the push button output when it is released.