Thursday, May 14, 2009


Been a bit lazy lately, been trying to buy our first house, and it is consuming a lot of my time, and is exceedingly frustrating. Aaaanyway here is a post about inputs!

So we've more or less got lights working, but now we're going to need a way to detect what buttons have been pressed and when. Remember how the 4094 chips were serial in, parallel out?? Well we're going to use a slightly different chip called the 74HC165 (which will be affectionately known as a 165 chip from now on). It takes parallel inputs, and converts them all into a handy dandy serial output for you. They work in much the same way as the 4094 chips do, but instead of setting a bit to 1 or 0, we will be reading a 1 or 0 bit to determine the current state of a switch.

Initially i had breadboarded this and it worked out fine, however when i started wiring this up to actual switches on the pinball machine, i ran into one major problem - which was almost a show-stopper. See when a pinball runs over a switch embedded in the playfield, the switch is only pressed momentarily. Now unless im checking the state of the switch at that exact time, the switch is going to read 0. Since I cant guarantee that the state will be read when its pressed down, this means i would miss out on some switch presses, which is a bad thing (tm).

Back in the day when i was writing video games for a living, we had something called a was-pressed state as well as an is-pressed state for each button. So at any stage we can know if the button is currently pressed or had been pressed in the past. I wanted to implement something similar for the pinball (maybe without the is-pressed as all switches will be momentary). I realised that i needed to do this with hardware, so i'd need a flip-flop. A flip flop can store exactly 1 bit of data, and in this case will be storing a switches state. There are various different kinds of flip-flops which work slightly differently, however i decided to go with a simple S-R (set-reset) model, which i made myself.

Next post will be alllll about flip flops for your reading pleasure.

No comments: