Sorry forgot to include compiler WIN AVR avr-gcc (GCC) 3.4.1
Thanks you hit the nail on the head.
Changed it to
if (PIND & (1<<PIND4))
and it is working.
-----Original Message-----
From: Larry Barello [mailto:yahoo@barello.net]
Sent: Monday, January 17, 2005 11:16 PM
To: AVR-Chat@yahoogroups.com
Subject: RE: [AVR-Chat] Testing a switch on ATMega128
What is "PIND4"? You wouldn't happen to mean PIND.4 or (PIND &
(1<<PIND4)) or PIND.PD4 or some variation like that? Which compiler?
-----Original Message-----
From: wbounce
I have the following
5v ------ switch ------10K resistor --- ground
|
|-- 330 resistor -- PORTD4
This is supposed to be a switch with a pull down resistor.
By default the pull up resistors should be on for a Atmega128 so I did
the following
DDRD &= 0xEF; // turn pin4 to input
PORTD &= 0xEF; // write 0 to pin4 to disable pullup
printf("pinb %i ",PIND4);
if (PIND4)
{
PORTB ^= 0x01; // off LED
Yahoo! Groups LinksMessage
RE: [AVR-Chat] Testing a switch on ATMega128
2005-01-19 by wbounce
Attachments
- No local attachments were found for this message.