You Are Here: Home » AVR ATmega Projects » Interfacing(USB - RS232 - I2c -ISP) Projects » How to take input from a particular pin of ATmega16

How to take input from a particular pin of ATmega16




For understanding the human needs a system must be able to take input from user. The devices which can be used to take input for a system are keypad, touch screen, etc. In the article LED blinking, the microcontroller drives the LED or in embedded language the microcontroller was set to give o/p, this article gives brief information of getting an input from user at a particular pin of microcontroller.

How to take input from a particular pin of ATmega16

In order to take input from an external source on any of the pins of the AVR microcontroller, the pins need to be configured as input pin. This configuration informs the controller that the corresponding pins are used to take input. The following steps explain how to take input from a pin:

 

Step1: Set the direction of PORT
To use a port as an input port first set the direction of port. DDRx (Data Direction) Register is used to set the direction of port.
DDRA=0x00;
In DDRA, ‘A’ shows the portA and 0x00 sets all the pins of port as input pins. (Writing 0 in DDR makes it input pin and writing 1 in DDR makes it output pin.
How to take input from a particular pin in AVR ATmega16 circuit
Step2: To take input form a port
Make a variable and use PINx instruction to get the input from a port
Value=PINA;
Where Value is a variable.

Leave a Comment

You must be logged in to post a comment.

Read previous post:
Scientists find ‘outlier’ enzymes, potential new targets to treat diabetes, inflammation

A team led by scientists at The Scripps Research Institute (TSRI) and the Salk Institute for Biological Studies has discovered...

Close
Scroll to top