Skip to content

Instantly share code, notes, and snippets.

@schappim
Created December 19, 2017 10:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schappim/dfed4724a30428de394e6a93597f5c55 to your computer and use it in GitHub Desktop.
Save schappim/dfed4724a30428de394e6a93597f5c55 to your computer and use it in GitHub Desktop.
int led = 13; // We are going to make Pin 13 LED blink
int threshold = 28; // Change this to the level you want the light to come on
int volume;
void setup() {
Serial.begin(9600);
pinMode(led, OUTPUT);
}
void loop() {
volume = analogRead(A0); // Read the value from the Analog PIN A0
Serial.println(volume);
delay(100);
if (volume >= threshold) {
digitalWrite(led, HIGH); //Turn ON Led
} else {
digitalWrite(led, LOW); // Turn OFF Led
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment