Hi there, I’m trying to get Wav Trigger tracks to play when a potentiometer is between certain values and a button is pressed (via Arduino Uno). I can get LEDs to light with this action but no tracks play. It feels like I’ve tried everything so maybe it’s some kind of response time issue with the Wav Trigger…? Any ideas…? Thanks!
Here’s my code:
#include “AltSoftSerial.h”
#include “wavTrigger.h”
wavTrigger wTrig;
const int led = 13;
const int button = 2;
int buttonState = 0;
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(57600);
pinMode (led, OUTPUT);
pinMode (button, INPUT);
}
// the loop routine runs over and over again forever:
void loop() {
buttonState = digitalRead(button);
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// print out the value you read:
Serial.println(sensorValue);
delay(50); // delay in between reads for stability
if ((sensorValue > 0) && (sensorValue < 201)){
digitalWrite (led, LOW);
}
if ((sensorValue > 200) && (sensorValue < 301) && (buttonState == HIGH)){
digitalWrite (led, HIGH);
wTrig.trackPlaySolo(1);
}
if
((sensorValue > 200) && (sensorValue < 301) && (buttonState == LOW)){
digitalWrite (led, LOW);
}
if ((sensorValue > 300) && (sensorValue < 501)){
digitalWrite (led, LOW);
}
if ((sensorValue > 500) && (sensorValue < 601) && (buttonState == HIGH)){
digitalWrite (led, HIGH);
wTrig.trackPlaySolo(2);
}
if ((sensorValue > 500) && (sensorValue < 601) && (buttonState == LOW)){
digitalWrite (led, LOW);
}
if ((sensorValue > 600) && (sensorValue < 701)){
digitalWrite (led, LOW);
}
if ((sensorValue > 700) && (sensorValue < 800) && (buttonState == HIGH)){
digitalWrite (led, HIGH);
wTrig.trackPlaySolo(3);
}
if ((sensorValue > 700) && (sensorValue < 800) && (buttonState == LOW)){
digitalWrite (led, LOW);
}
if (sensorValue > 800) {
digitalWrite (led, LOW);
}
}