const int motionPin = 2; // Harakat datchigini ulash uchun digital pin raqami
const int ledPin = 9; // LED chiroqni ulash uchun digital pin raqami
void setup() {
pinMode(motionPin, INPUT); // Harakat datchigini kiritish uchun pin raqamini chiqish sifatida sozlash
pinMode(ledPin, OUTPUT); // LED chiroqni chiqarish uchun pin raqamini chiqish sifatida sozlash
Serial.begin(9600); // Serial portni boshlash
}
void loop() {
int motionValue = digitalRead(motionPin); // Harakat datchigidan o'qish
if (motionValue == HIGH) {
digitalWrite(ledPin, HIGH); // Agar harakat aniqlansa, LED chiroqni yoqish
Serial.println("Harakat aniqlandi!"); // Serial portga harakat aniqlandi degan xabar yozish
} else {
digitalWrite(ledPin, LOW); // Agar harakat aniqlanmasa, LED chiroqni o'chirish
Serial.println("Harakat aniqlanmadi."); // Serial portga harakat aniqlanmadi degan xabar yozish
}
delay(100); // To'xtash uchun kichik o'rtacha chegaralash
}