Flashing Light Prize (3) Arduino Scat
Sparkfun sound detector triggered by the relay triggers the relay, rinse, repeat. Skiddily bee bop ba doo bop skiddily dee bip boop bop, yeah.


Ingredients
1. Arduino Uno
2. Sparkfun Sound Detector
3. 5V Relay
4. NPN Transistor
5. 1K Res
6. (2) Candle Incandescent Bulbs
7. Cuhlness



Notation(s)
1. Special guest mouth hornist, Vije Miller -- the horniest.
2. Zappa dee doo blip blop biddily doo wap be zah.

Sketchity Zoopity Zow
// Flashing Light Prize (3) Arduino Scat
// VijeMiller

// Sound Detector Pins
#define PIN_GATE_IN 2
#define IRQ_GATE_IN 0
#define PIN_LED_OUT 13
#define PIN_ANALOG_IN A0

// Relay Pin
int relay = 7;

// Sound Value
int val;

// SparkFun Sound Detector Interrupt
void soundISR()
{
int pin_val;
pin_val = digitalRead(PIN_GATE_IN);
digitalWrite(PIN_LED_OUT, pin_val);
}

void setup()
{
// Testing
Serial.begin(9600);
// Sound Detector Pin Assignment
pinMode(PIN_LED_OUT, OUTPUT);
pinMode(PIN_GATE_IN, INPUT);
// Relay Pin Assignment
pinMode(relay, OUTPUT);
// Sound Decector Interrupt
attachInterrupt(IRQ_GATE_IN, soundISR, CHANGE);
}

void loop()
{

// Read Sound
val = analogRead(PIN_ANALOG_IN);
// Testing
Serial.println(val);
// If Sound Exceeds X
if (val > 55) {
digitalWrite(relay, HIGH);
delay(600);
digitalWrite(relay, LOW);
delay(200);
} else {
digitalWrite(relay, LOW);
}

delay(10);
}

Archive
https://hackaday.io/project/25869-flashing-light-prize-3-arduino-scat

01:50:6 116-017