Created
July 16, 2018 10:12
-
-
Save elktros/7404ac2ed213db137bab9248caaf7db6 to your computer and use it in GitHub Desktop.
Code for interfacing sound sensor with Arduino.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int ledPin = 12; | |
const int soundPin = 7; | |
int soundVal = 0; | |
void setup () | |
{ | |
pinMode (ledPin, OUTPUT); | |
pinMode (soundPin, INPUT); | |
} | |
void loop () | |
{ | |
soundVal = digitalRead(soundPin); | |
if (soundVal == LOW) | |
{ | |
digitalWrite(ledPin, HIGH); | |
} | |
else | |
{ | |
digitalWrite(ledPin, LOW); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment