Skip to content

Instantly share code, notes, and snippets.

@elktros
Created July 16, 2018 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elktros/7404ac2ed213db137bab9248caaf7db6 to your computer and use it in GitHub Desktop.
Save elktros/7404ac2ed213db137bab9248caaf7db6 to your computer and use it in GitHub Desktop.
Code for interfacing sound sensor with Arduino.
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