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.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top