//LED chiroqlariga signallar uzatilishini Button (tugmacha) orqali boshqarishga
//misollar keltiring
const int buttonPin = 2; // Tugmach pinining raqami
const int ledPin1 = 13; // Birinchi LED chiroqning pinining raqami
const int ledPin2 = 12; // Ikkinchi LED chiroqning pinining raqami
int buttonState = 0; // Tugmacha holatini saqlash uchun o'zgaruvchi
void setup() {
pinMode(ledPin1, OUTPUT); // LED chiroqni chiqaruvchi sifatida sozlash
pinMode(ledPin2, OUTPUT); // LED chiroqni chiqaruvchi sifatida sozlash
pinMode(buttonPin, INPUT); // Tugmacha uchun INPUT sifatida sozlash
}
void loop() {
buttonState = digitalRead(buttonPin); // Tugmacha holatini o'qish
if (buttonState == HIGH) { // Agar tugmacha bosilsa
digitalWrite(ledPin1, HIGH); // Birinchi LED chiroqni yonishini o'zgartirish
digitalWrite(ledPin2, LOW); // Ikkinchi LED chiroqni yonishini o'zgartirish
} else {
digitalWrite(ledPin1, LOW); // Agar tugmacha bosilmasa, birinchi LED chiroqni o'chirish
digitalWrite(ledPin2, HIGH); // Ikkinchi LED chiroqni yonishini o'zgartirish
}
}