Reading Switches

Switches are arguably the most important element in a pinball machine.  Early pinball machines did not have flippers.  You just launched a ball and watched it fall through the playfield.  Switches are the primary interaction between the ball and the game play.  Without switches you cannot register where the ball is, and you cannot turn on lights or play sounds when a ball reaches particular targets.

My goal in handling the reading of switches was to find a solution that did not require a constant scanning of switches.  With up to 64 possible switches the constant polling of those switches takes up a lot of processing power and can lead to missing inputs if your program and processor can’t scan the switches fast enough.

My solution is to use the 64 Button Arduino compatible Shield from SpikenzieLabs:

http://www.spikenzielabs.com/SpikenzieLabs/Button64Shield.html

http://www.spikenzielabs.com/SpikenzieLabs/Project_64.html

The shield is reasonably priced.  Unassembled it is around $24 and assembled around $33.

The company also recommends using diodes in you button matrix.  They offer 100 1N4148TA Diodes for $5.  With the use of the diodes the shield can read multiple button presses simultaneously.

The best part of this shield is it is interrupt driven.  The shield takes care of scanning the inputs, and when a switch press is detected, your code can fire off an interrupt handler method to handle the input.

Furthermore, the 64 Button Shield can communicate with a host processor (Arduino) using SPI or a standard serial port.  Having this option allows me to use SPI to communicate between the Arudino and the 64 Button Shield, and then use the Arudino serial port to send input data to my main processor (PC).

The 64 Button Shield allows you to wire up to 64 buttons in a matrix (although this is not required).  With a matrix wiring pattern, you only need 16 wires (8 rows x 8 columns) to address all 64 switches.

 

TO DO…

Leave a Reply

Your email address will not be published. Required fields are marked *


nine + = 18

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>