I am trying to add a sound trigger to my code, but nothing I’ve done seems to work.
things I’ve tried:
compared strings with == and .equals
used a boolean
made the arduino send a number instead of a string to compare
here is a copy of my code:
import processing.sound.*;
static String alert="intruder alert!";
void setup(){
file = new SoundFile(this, "intruder.mp3");
file.amp(0.5);
}
void draw(){
while(mySerial.available() >0){
myString = mySerial.readStringUntil(nl);//Strip data of serial port
if(myString !=null){
background(0);
myVal=float(myString);
print(myString);
if(myString.equals(alert)){
file.play(1);
}
}
}
}