bool btn_state; // a variable where we store the state of the button, we can give it any name but it is better to choose a name that make sense and is not confusing
void setup() {
pinMode(7, OUTPUT); // setting LED (connected to pin 7) as OUTPUT because Arduino gives Data(ON/OFF) to LED
pinMode(13, INPUT); // setting buttong (connected to pin 13 (through the purpul wire)) as INPUT because Arduino takes Data(Pressed or not pressed) from the button
}
void loop() {
btn_state = digitalRead(13); // we use the variable through pin 13 where the Arduino reads the state of the button(pressed or not) and we store the information in this variable
digitalWrite(7,btn_state); // instead of HIGH/LOW we use the variable(btn_state) in which the state of the button is stored. this way if the button is pressed it will take the place of HIGH, and the place of LOW if otherwise
/* NOTE: make sure that the button and the LED are connected to same ground; otherwise the circuit will always open and it will not work */
}