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.
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.
Step2:To take input form a port
Make a variable and use PINx instruction to get the input from a port
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.
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.ACCEPTPrivacy Policy
Manage consent
Privacy Overview
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.