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 Eric

Oh-dam-it
I forgot to say I was going to focus on the assembly code for now, and try out my C coding after the book
comes, that Amazon stuff up really got me worked up, I just got a email to say one two piece order is on
the way. I hope they picked up the double order mistake.


From Eric





----- Original Message -----
From: "Eric" <erichards@clear.net.nz>
To: <AVR-Chat@yahoogroups.com>
Sent: Saturday, February 19, 2005 8:32 AM
Subject: Amazon Re: [AVR-Chat] The keyboard



Thank you for your response I have that book

"Embedded C Programming and the Atmel AVR"
Barnett, Cox & O'Cull
                  A Thomson - Delmar Learning Publication
                              ISBN: 1401812066

coming from Amazon UK last night, I wanted two things, I stuffed the order up and could not cancel the
mess up I was going round and round in endless loops trying to find a way, I hope I don't have two books
coming or I will not purchase from them again, there is no direct feedback for such orders mess-ups, so
be it a lesson, it might of been better if I had of had my order come as two separate deliveries.


From Eric




----- Original Message -----
From: "Jose Fuentes" <josecarlosfuentes@yahoo.com.ar>
To: <AVR-Chat@yahoogroups.com>
Sent: Saturday, February 19, 2005 4:03 AM
Subject: Re: [AVR-Chat] The keyboard



I recommend you to use at least 330 ohms resistors on
all the pins used for the keyboard.  Otherwise you
could unintentionally damage the ports, for instance
you could inadvertedly put all the pins as ouputs and
make a short-circuit with the switches.

I would scan the keyboard this way:

//PORTA.0:3 OUTPUTS
//PORTA.4:7 INPUTS

unsigned char i;
unsigned char result[4];
DDRA = 0x0F;//set direction (input/output)
PORTA = 0xFF;//activate pull-ups
for(i = 0; i < 4; i++)
{
  PORTA = ~(0x01 << i);//put 0s in PORTA.0:3
  result[i] = PINA;
}

If you want to save RAM memory (3 bytes) you can do
the following:
//PORTA.0:3 OUTPUTS
//PORTA.4:7 INPUTS

unsigned char result[2];
DDRA = 0x0F;//set direction (input/output)
PORTA = 0xFF;//activate pull-ups

PORTA = ~(0x01 );//put 0 in PORTA.0
result[0] = PINA | 0x0F;

PORTA = ~(0x01 << 1);//put 0 in PORTA.1
result[0] &= ((PINA >> 4) | 0xF0);

PORTA = ~(0x01 << 2);//put 0 in PORTA.2
result[1] = PINA | 0x0F;

PORTA = ~(0x01 << 3);//put 0 in PORTA.3
result[1] &= ((PINA >> 4) | 0xF0);

Then you have to check the bits in 'result' variable,
a 0 means a pressed switch.
This code is just an idea, I haven't tested it yet.


Regards

Jose

 --- Eric <erichards@clear.net.nz> escribió:
>
> Hi what a failure the project is.
>
> I was planning to put a 4*4 keyboard on portA of a
> ATmega32, sending F0 to the data direction register
> &
> the data port.
>
> this is the "test" plan, to put 1's on all the rows,
> the loop will look for a 1 on the columns,  when it
> finds a 1 the beeper will beep, then I will continue
> to write the code so to put information on the LCD
> from the keyboard after strobbing the rows one by
> one.
>
>
> I got it to work alright on the studio program, it
> loops round looking for a 1 on the columns,  but it
> fails when I download it to the micro,
> I have got the port lines going direct to the
> keyboard,  should I put say 10K resistors on the
> input
> ports? or use some other hardware ideas?
>
>
>
> From Eric
>
>
>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>     AVR-Chat-unsubscribe@yahoogroups.com
>
>
>
>
>
>






___________________________________________________________
250MB gratis, Antivirus y Antispam
Correo Yahoo!, el mejor correo web del mundo
http://correo.yahoo.com.ar



Yahoo! Groups Links










Yahoo! Groups Links

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.