To understand what a pull-up resistance is, we take a look at the following figure .
One end of the switch is connected to ground while the other end is connect to Vcc through a resistance R1 (known as pull-up resistor). This end is also connected to the microcontroller. So, the effective voltage at the input pin, when the switch is open, is Vcc. Now, as soon as the switch is pressed, the current will flow through the switch towards the ground, effectively giving us a LOW logic level at the input pin.Whenever the switch is open, the resistance R1 drives the input pin to HIGH logic level. This action is called pull-up.
Interestingly, the Atmega16 chip comes with a built-in pull-up resistor,i.e, we are not required to place an addition resistor and Vcc connection physically. This can be easily done with a single line of code. This is known as activating pull-up resistance.
To activate pull-up resistance in atmega16, first declare the port as an input port and then write HIGH on that port.
One end of the switch is connected to ground while the other end is connect to Vcc through a resistance R1 (known as pull-up resistor). This end is also connected to the microcontroller. So, the effective voltage at the input pin, when the switch is open, is Vcc. Now, as soon as the switch is pressed, the current will flow through the switch towards the ground, effectively giving us a LOW logic level at the input pin.Whenever the switch is open, the resistance R1 drives the input pin to HIGH logic level. This action is called pull-up.
Interestingly, the Atmega16 chip comes with a built-in pull-up resistor,i.e, we are not required to place an addition resistor and Vcc connection physically. This can be easily done with a single line of code. This is known as activating pull-up resistance.
To activate pull-up resistance in atmega16, first declare the port as an input port and then write HIGH on that port.
No comments:
Post a Comment