Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // KY-038 Microphone Module (Sensor) (Digital version)
- int ledPin = 13;
- int sensorPin = 9;
- boolean val = 0;
- void setup() {
- pinMode(ledPin, OUTPUT);
- pinMode(sensorPin, INPUT);
- }
- void loop () {
- val = digitalRead(sensorPin);
- // When the sensor detects a signal above the threshold value, LED flashes
- if (val == HIGH) {
- digitalWrite(ledPin, LOW);
- }
- else {
- digitalWrite(ledPin, HIGH);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment