Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: Amazon Re: [AVR-Chat] The keyboard

2005-02-18 by Dave VanHorn

At 03:39 PM 2/18/2005, Stefan Trethan wrote:

>On Fri, 18 Feb 2005 15:34:36 -0500, Dave VanHorn <dvanhorn@dvanhorn.org>
>wrote:
>
> >
> >>
> >> I am currently making something with a 3x4 keyboard.
> >> I have connected the 3 columns to the 3 external iterrupts, and the 4
> >> rows
> >> to I/O.
> >> The plan is to set the column pins (interrupts) to pullup, and input,
> >> and
> >> the rows to output, low.
> >> My hope is when someone presses a key the interrupt line goes low,
> >> causing
> >> a interrupt and in the ISR i switch the rows input and columns output to
> >> see which button it was.
> >>
> >> Would be nice to know if this will actually work, i just guessed...
>
> > Sounds right to me, just set a timer to change the row outputs
> > periodically, say every 100mS or so.
>
>
>Thanks,
>
>but why should i change the row outputs?
>I thought i let them all low, until there's a interrupt, and in the ISR i
>change the rows from out to in and make the colums low. The row input that
>goes low would show the pressed key?

Well, let's just say inputs and outputs.
Assume a 4x4 matrix.
When I get a low, maybe I read 0xXE so bit 0 of the port is low.
That tells me that a key in a given row is pressed, but I need to know 
which col is low, to know which key that is.

So, have an event, probably on timer 0, that every so often, changes which 
col is low, and at the same time, writes new definitions into four bytes in 
ram.  So when Col0 is low, it writes A,B,C,D  A while later it takes Col0 
high and Col1 low, and writes E,F,G,H, and so on.

When you get the int, then you see 0x07, and you know that row 3 was 
pushed, so you load "H" from ram into TEMP, and return that "H" was pressed.

You could also just go look at the row and col inputs, and use them to look 
up a table, or handle it many other ways.

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.