Lesson-2: Led Burning With Arduino Button
Led Burning With Arduino Button
LECTURE VIDEO:

Necessary Materials:
Ardunio Uno Card
Experimental Circuit (Bread Bord)
Red Led
Button
330 ohm resistance
10K ohm resistance
First, we connect the button to the center of our circuit. Because it has a light rectangular structure, it can be installed one way and the other direction does not fit the circuit. When the front of the button turns to you, we connect one of the legs on the left side +5V. And the next leg is tied to pine number 8 on the Ardunio card. Since the button is sensitive, we also connect the leg that we connect to pin number 8 to the GND pin with a resistance of 10K, so that it is affected by our body and surrounding magnetic fields.
In our queue led, long leg, that is, anode U 330 ohm resistance with Ardunio Cardda number 10 pine is connected. The reason we install resistance is because it does not damage our +5V led. We connect the cathode leg of the LED, that is, the short leg, to the GND pin.
Our circuit is ready. Now we can look at the codes:
int durum=0;
void setup() {
pinMode (10,OUTPUT);
pinMode (8,INPUT);
}
void loop() {
durum=digitalRead(8);
if (durum ==1 ){
digitalWrite(10,HIGH);
}
else{
digitalWrite(10,LOW);
}
}
10 in Void setup. pini output (led pini), 8. we set the pin as input (button pin). In the upper part, we defined a variable named status. This variable will take values into it according to the button press condition.
In the Void loop section, durum = digitalRead(8); the status of pressing the button is registered in the status variable. Reads data from pin number 8 and stores it in the state. Then, with the IF else structure, the Led is lit and extinguished according to the state of the state variable being 0 or 1. He saw the Led light up and go out in the previous trouble.
Visuals:

