Read the data sheet for your part
But this is my understanding.
Working with port B
Set port B to output and output a logical high to pin 0
DDRB = 0xFF;
PORTB |= 1;
Set port B pin 0 to input with pullup register on
PORTB |= 1;
DDRB = 0xFE;
Set port B pin 0 to input with pullup register off
PORTB |= 1;
DDRB = 0xFF;
Read port B pin 0
Myvar = (PINB & 1);
Summary
Set DDRB to 1 for output 0 for input
For input write a 1 to that pin to enable pullup 0 to disable pullup
The PINB can be used to read the port at anytime.
Hope this helps
-----Original Message-----
From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On
Behalf Of aswinefy2003
Sent: Tuesday, August 09, 2005 12:40 AM
To: AVR-Chat@yahoogroups.com
Subject: [AVR-Chat] help/reading I/0 pins
Hello
Can any one give a sample code for
reading the value of a i/o PIN. Also tell
me role of pull up resistor in doiing so.
Yahoo! Groups LinksMessage
RE: [AVR-Chat] help/reading I/0 pins
2005-08-09 by wbounce
Attachments
- No local attachments were found for this message.