//https://www.arduino.cc/reference/en/language/functions/digital-io/digitalread/
int ledPin = 2; // LED connected to digital pin 2
int inPin = 7; // pushbutton connected to digital pin 7
int val = 0; // variable to store the read value
void setup() {
// put your setup code here, to run once:
pinMode(ledPin, OUTPUT); //sets the digital pin 2 as output
pinMode(inPin, INPUT); // sets the digital pin 7 as input
}
void loop() {
// put your main code here, to run repeatedly:
val = digitalRead(inPin); // read the input pin
digitalWrite(ledPin, val); // sets the LED to the button's value
}