[net.micro.amiga] switch state detection

lwall@sdcrdcf.UUCP (Larry Wall) (09/18/86)

For a quizzing application, I'd like to hook 8 switches up to the
parallel interface and determine which switch closes first.  Can this
be done, and if so, what is the easiest way to go about it?  It seems
to me that if I strobe it right, I can just read the first character that
shows up on the parallel interface and see which bit is set.

I know just enough about electronics to suspect that if I short the 5v power
to the data pins I might smoke something.  Either direct advice or pointers
to how-to-do-its would be welcome.  I don't want to smoke my baby computer!

Larry Wall
{allegra,burdvax,cbosgd,hplabs,ihnp4,sdcsvax}!sdcrdcf!lwall

stever@videovax.UUCP (Steven E. Rice) (09/19/86)

In article <3012@sdcrdcf.UUCP>, Larry Wall (lwall@sdcrdcf.UUCP) writes:

> For a quizzing application, I'd like to hook 8 switches up to the
> parallel interface and determine which switch closes first.  Can this
> be done, and if so, what is the easiest way to go about it?  It seems
> to me that if I strobe it right, I can just read the first character that
> shows up on the parallel interface and see which bit is set.
> 
> I know just enough about electronics to suspect that if I short the 5v power
> to the data pins I might smoke something.  Either direct advice or pointers
> to how-to-do-its would be welcome.  I don't want to smoke my baby computer!

In general, inputs float to a "1" state and must be pulled down to a "0"
state (untrue for CMOS -- they tend toward a guaranteed floating "maybe"!).
Pull up each data bit to +5 volts through a 4.7K resistor (this puts a "1"
on the input).  Then connect the switch so it pulls the input down to
ground ("0") when the button is pushed.

Mechanical switches of all kinds "bounce" as they open and close -- their
contacts make and break (or break and make) contact several times before
they become fully closed (or open).  You may want to read the input at
10 millisecond intervals and require that a line that changes be in the
same (new) state for three successive reads before accepting it as valid.

					Steve Rice

----------------------------------------------------------------------------
{decvax | hplabs | ihnp4 | uw-beaver}!tektronix!videovax!stever