Compare commits
No commits in common. 'fdd92295256b09cea0be7e054104a1c91325fac1' and 'f267028af128d4b164e0a2b9c52d545c852c1693' have entirely different histories.
fdd9229525
...
f267028af1
@ -1,36 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* Trigger Detect
|
||||
*
|
||||
*
|
||||
* Detecting triggers is essential to interact with other modules, for example to generate short bursts of sounds
|
||||
* Try the output of simple-lfo.ino with this patch and open the serial monitor to see what happens!
|
||||
*
|
||||
* A3 = Trigger in
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
bool triggered; // logic: trigered, yes or no
|
||||
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600); // debugging (see if trigger is registered)
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
int input3 = digitalRead(A3); // read analog pin 3
|
||||
|
||||
// trigger
|
||||
if(input3 && !triggered) { //if there is a reading on input3 and the bool condition triggered is not true do
|
||||
Serial.println("I hear a trigger!");
|
||||
// DO SOMETHING ON TRIGGER HERE
|
||||
triggered = true;
|
||||
}
|
||||
else if(!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 ;)
|
||||
triggered = false;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue