const int TOUCH_SENSOR_PIN = 7; // kontrollerning pin oyoqchasiga sensorni tanishtirish
const int BUZZER_PIN = 3; // kontrollerning pin oyoqchasiga tovush qurulmasini tanishtirish
void setup() {
Serial.begin(9600); // seriyani ishga tushiring
pinMode(TOUCH_SENSOR_PIN, INPUT); // kontroller pinini kirish rejimiga o'rnating
pinMode(BUZZER_PIN, OUTPUT); // kontroller pinini chiqish rejimiga o'rnating
}
void loop() {
int touchState = digitalRead(TOUCH_SENSOR_PIN); // Holatni o‘qish
if (touchState == HIGH) {
Serial.println("Sensorga kirish signali berilmoqda");;
digitalWrite(BUZZER_PIN, HIGH); // Ovoz qurulmasi yoqish
}
else
if (touchState == LOW) {
Serial.println("Sensor tinch xolatda");
digitalWrite(BUZZER_PIN, LOW); // Ovoz qurulmasini o’chirish
}
}
Do'stlaringiz bilan baham: |