Arduino deneyi 05
Sound-Activated LED
Beginner · 40 min · Sensor input
Use a digital sound sensor module to flash an LED when it detects a loud sound.
Malzemeler
- Arduino Uno
- Digital sound sensor module
- LED
- 220 Ω resistor
- Breadboard and jumper wires
Bağlantı
- Connect sensor VCC to 5V, GND to GND and digital OUT to pin 2.
- Connect pin 13 through 220 Ω to the LED anode; connect the cathode to GND.
Kod
const int soundPin = 2;
const int ledPin = 13;
void setup() {
pinMode(soundPin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
if (digitalRead(soundPin) == HIGH) {
digitalWrite(ledPin, HIGH);
delay(200);
} else {
digitalWrite(ledPin, LOW);
}
}
Ne olmalı?
A loud sound triggers a short LED flash.
Meydan okuma
Adjust the module potentiometer and compare sensitivity.
Güvenlik ve sorun giderme
- Bağlantıyı değiştirmeden önce gücü kes.
- Her LED ile direnç kullan.
- Kart ve port seçimini Arduino IDE'de kontrol et.
- Her kablonun koddaki pin numarasıyla eşleştiğini doğrula.
Not: Ders metinleri İngilizcedir. Orijinal Türkçe çalışma kâğıdı PDF olarak indirilebilir.
