Digital Inputs

Materials Needed:

  • (1) 5mm Red LED
  • (1) 270 Ω Resistor (red, purple, brown stripes) 
  • (2) Push buttons
  • (1) Half-size breadboard
  • (1) Arduino Uno R3
  • Jumper wires 

Code:

int ledPin = 5;

int buttonApin = 9;

int buttonBpin = 8;

 

byte leds = 0;

 

void setup() 

{

  pinMode(ledPin, OUTPUT);

  pinMode(buttonApin, INPUT_PULLUP);  

  pinMode(buttonBpin, INPUT_PULLUP);  

}

 

void loop() 

{

  if (digitalRead(buttonApin) == LOW)

  {

    digitalWrite(ledPin, HIGH);

  }

  if (digitalRead(buttonBpin) == LOW)

  {

    digitalWrite(ledPin, LOW);

  }

}

Layout:

Schematic: