Yahoo Groups archive

AVR-Chat

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

Message

RE: [AVR-Chat] help/reading I/0 pins

2005-08-09 by wbounce

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 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.