const int greenLedPin = 9; // Yashil chiroqning pin raqami
const int redLedPin = 10; // Qizil chiroqning pin raqami
const int yellowLedPin = 11; // Sariq chiroqning pin raqami
const int button1Pin = 2; // Birinchi knopkaning pin raqami
const int button2Pin = 3; // Ikkinchi knopkaning pin raqami
const int button3Pin = 4; // Uchinchi knopkaning pin raqami
void setup() {
pinMode(greenLedPin, OUTPUT); // Yashil chiroqni chiqish sifatida sozlash
pinMode(redLedPin, OUTPUT); // Qizil chiroqni chiqish sifatida sozlash
pinMode(yellowLedPin, OUTPUT); // Sariq chiroqni chiqish sifatida sozlash
pinMode(button1Pin, INPUT); // Birinchi knopkani kirish sifatida sozlash
pinMode(button2Pin, INPUT); // Ikkinchi knopkani kirish sifatida sozlash
pinMode(button3Pin, INPUT); // Uchinchi knopkani kirish sifatida sozlash
}
void loop() {
// Birinchi knopkani tekshirish
if (digitalRead(button1Pin) == HIGH) {
digitalWrite(greenLedPin, HIGH); // Yashil chiroqni yonsin
} else {
digitalWrite(greenLedPin, LOW); // Yashil chiroqni o'chirsin
}
// Ikkinchi knopkani tekshirish
if (digitalRead(button2Pin) == HIGH) {
digitalWrite(redLedPin, HIGH); // Qizil chiroqni yonsin
} else {
digitalWrite(redLedPin, LOW); // Qizil chiroqni o'chirsin
}
// Uchinchi knopkani tekshirish
if (digitalRead(button3Pin) == HIGH) {
digitalWrite(yellowLedPin, HIGH); // Sariq chiroqni yonsin
} else {
digitalWrite(yellowLedPin, LOW); // Sariq chiroqni o'chirsin
}
}