001d_Buttons

Project Overview:

Create a project that can make the Arduino turn on an LED with the push of a button. For this assignment I will be using a tactile push button and a pull down resistor.

Code:

int btn2 = 2;

int led = 9;

 

void setup() {

  pinMode(led, OUTPUT);

  pinMode (btn2, INPUT);   

}

 

void loop() {

  if(digitalRead(btn2) == HIGH){

  digitalWrite (led, HIGH);

  }

  else{

  digitalWrite (led, LOW);

  }

}

Schematic:

Layout:

What I learned / Problems:

What I leaned:

  • I learned how to wire a pull down resistor with a push button.
  • I also learned to get input from a push button.

Problems:

  • None