Skip to content

Instantly share code, notes, and snippets.

@benrules2
Created January 24, 2019 01:39
Show Gist options
  • Save benrules2/9b6c730084e6fbb46ca1c8b4036e8c9c to your computer and use it in GitHub Desktop.
Save benrules2/9b6c730084e6fbb46ca1c8b4036e8c9c to your computer and use it in GitHub Desktop.
Billy Bass Audio Diagnostic
int sensorPin = A0; // select the input pin for the audio signal input
int ledPin = 13;
void setup() {
// declare the ledPin as an OUTPUT and sensorPin as input
pinMode(ledPin, OUTPUT);
pinMode(sensorPin, INPUT);
Serial.begin(9600); // open the serial port at 9600 bps:
}
void loop() {
int quietThreshold = 3;
int sensorValue = analogRead(sensorPin);
if(sensorValue > quietThreshold) {
digitalWrite(ledPin, HIGH);
Serial.println("Music IS playing!");
Serial.print("sensorValue: ");
Serial.println(sensorValue);
} else {
digitalWrite(ledPin, LOW);
Serial.println("Music is NOT playing.");
Serial.print("sensorValue: ");
Serial.println(sensorValue);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment