Friday, May 27, 2016

Pull-up and Pull-down Resistor Tutorial

In this post we take a look at what are pull-up and pull-down resistors, their purpose, and where to use them.



Arduino code from video:
void setup() {
  // put your setup code here, to run once:
  pinMode(3,INPUT);
  pinMode(6,INPUT_PULLUP);
  pinMode(5,INPUT);
  pinMode(4,INPUT);
  pinMode(2,INPUT);
  Serial.begin(57600);

}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.print("This is the pull-up input D6 ");
  Serial.println(digitalRead(6));
  Serial.print("D5 input has no pull-up ");
  Serial.println(digitalRead(5));
   Serial.print("D4 input has no pull-up ");
  Serial.println(digitalRead(4));
  Serial.print("D3 input has no pull-up ");
  Serial.println(digitalRead(3));
   Serial.print("D2 input has no pull-up ");
  Serial.println(digitalRead(2));
  Serial.println();
  delay(1500);
}