added kick

master
dennisdebel 5 years ago
parent a986d013ea
commit 3eb890ef38

@ -7,7 +7,7 @@
*/
int pwmPin = 11; //define output pin, Meergranen output pin is 11
bool triggered; // logic: trigered, yes or no
bool triggered; // logic: triggered, yes or no
void setup() {
pinMode(pwmPin, OUTPUT); //set pin as output
@ -18,7 +18,7 @@ void loop() { // run forever
int input3 = digitalRead(A3); // read analog pin 3, detect triggers
if(input3 && !triggered) {
Serial.println("trigger!");
//ATTACK
for(int value = 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

@ -0,0 +1,63 @@
/*
*
* GABBER KICK (requires trigger input)
*
* // A2 sets pitch and delay of ATTACK (timbre)
* // A1 sets pitch and delay of SUSTAIN (actual phatness)
*
*/
#define SPEAKER_PIN 11
bool triggered; // logic: trigered, yes or no
void setup() {
// set pin 11 as output
pinMode(SPEAKER_PIN, OUTPUT);
Serial.begin(9600); // debugging (see if trigger is registered)
}
void loop() {
int input3 = digitalRead(A3); // read analog pin 3
if(input3 && !triggered) {
// analogWrite(11,0); //nasty attack try (speaker clip/click)
// delay(analogRead(A2));
// analogWrite(11,255);
// delay(analogRead(A2));
// analogWrite(11,0);
//ATTACK
for(int i=0;i<10;i++){ // i = DELAY+SUSTAIN+RELEASE of ATTACK
analogWrite(11,0);
delayMicroseconds(analogRead(A2)*i); // lower the pitch over time
analogWrite(11,255);
delayMicroseconds(analogRead(A2)*i); // lower the pitch over time
analogWrite(11,0);
// delay(1);
}
//delay(1);
//SUSTAIN RELEASE
for(int i=0;i<55;i++){ // i = DELAY+SUSTAIN+RELEASE
analogWrite(11,0);
delayMicroseconds(analogRead(A1)*i); // lower the pitch over time
analogWrite(11,255);
delayMicroseconds(analogRead(A1)*i); // lower the pitch over time
analogWrite(11,0);
delay(1);
}
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;
noTone(SPEAKER_PIN);
}
}
Loading…
Cancel
Save