Created
January 24, 2019 01:39
-
-
Save benrules2/9b6c730084e6fbb46ca1c8b4036e8c9c to your computer and use it in GitHub Desktop.
Billy Bass Audio Diagnostic
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
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