Arduino/elegoo-kit-lessons/Lesson 5 Digital Inputs/Digital_Inputs/Digital_Inputs.ino

28 lines
401 B
Arduino
Raw Permalink Normal View History

2022-02-20 21:05:40 +00:00
//www.elegoo.com
//2016.12.08
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);
}
}