In this tutorial, we are going to see PULL UP and PULL DOWN resistors and there uses.
The resistors are used to block the flow of current.
The pull up and pull down resistor are used in micro controller to clear or set the current flow in the path or reset the pin in the micro controller to 0 volt or 5 volt.
In this above image, the 3 rd pin is connected to the button which gives 5 V of supply when it is pressed and the LED D2 is turned ON.
If the button is released then the LED D2 must be turned OFF but it is Not turned OFF even the button is released this makes osillation of volatge in the 3rd pin of Arduino.
To clear this problem, the resistor are used to clear the volatge in the pin and it is grounded.
Here the resistor R1 is used as PULL DOWN resistor,Once the button is released ,the volatge in the 3 pin of Arduino is grounded via the resistor.
The R2 resistor act as PULL UP resistor,Once the button is pressed the 2 pin is grounded and the LED D1 is turned ON.
CODE
pinMode(2, INPUT);
pinMode(3, INPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
}
void loop()
if (digitalRead(2) == 0)
{
digitalWrite(4, HIGH);
}
else
{
digitalWrite(4, LOW);
}
if (digitalRead(3) == 1)
{
digitalWrite(5, HIGH);
}
else
{
digitalWrite(5, LOW);
}
}
HELPFUL INFORMATION
ReplyDelete