for(intvalue=0;value<=255;value++){// cycle through 255 values, start at 0. 8 bit output == 255 values
analogWrite(pwmPin,value);// analogWrite simulates smooth sinewave using complex pwm duty cycles
//DELAY
delay(1);
}
//SUSTAIN
for(intvalue=255;value>=0;value--){// cycle through 255 values, start at 0. 8 bit output == 255 values
analogWrite(pwmPin,value);// analogWrite simulates smooth sinewave using complex pwm duty cycles
delay(2);
}
//RELEASE
delay(20);
triggered=true;
}
elseif(!input3&&triggered){//if there is no reading on input3 and condition triggered is true (aka sound is playing), set triggered to false, aka stop playing
// STOP WHEN NO TRIGGER IS PRESENT (or do something else ;)