Skip to content

Instantly share code, notes, and snippets.

@laras126
Created April 27, 2011 23:23
Show Gist options
  • Select an option

  • Save laras126/945458 to your computer and use it in GitHub Desktop.

Select an option

Save laras126/945458 to your computer and use it in GitHub Desktop.
MP3 Trigger
#include <MP3Trigger.h>
MP3Trigger trigger;
const int piezoPin = A0; // piezo connected to analog pin 0
const int threshold = 100;
int valueP = 0;
int buttonState = 0;
void setup()
{
trigger.setup();
}
// Play a random track when sensor is activated.
void loop()
{
valueP = analogRead(piezoPin);
if (valueP > threshold)
{
int i = random(1,41);
trigger.trigger(i);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment