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.
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
Where Value is a variable.
Low cost PCB on PCBWay - only $5 for 10 PCBs and FREE first order for new members
PCB Assembly service starts from $88 with Free shipping all around world + Free stencil
PCBWay 2nd PCB Design Contest