Menu
Index
Engineering
Entertainment
Literature
Miscellaneous
Contact
Search
tiktok.com/@pkvi.xyz
scored.co/u/pkvi_mv
Why Ayh?
Miter
Miter
@pkvi
"...may not meet professional standards."
1767 miters
123 tenons
Subscribe
0.00955
Flashing Light Prize (3) Arduino Scat


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


  1. // Flashing Light Prize (3) Arduino Scat
  2. // pkvi
  3. // Sound Detector Pins
  4. #define PIN_GATE_IN 2
  5. #define IRQ_GATE_IN 0
  6. #define PIN_LED_OUT 13
  7. #define PIN_ANALOG_IN A0
  8. // Relay Pin
  9. int relay = 7;
  10. // Sound Value
  11. int val;
  12. // SparkFun Sound Detector Interrupt
  13. void soundISR()
  14. {
  15. int pin_val;
  16. pin_val = digitalRead(PIN_GATE_IN);
  17. digitalWrite(PIN_LED_OUT, pin_val);
  18. }
  19. void setup()
  20. {
  21. // Testing
  22. Serial.begin(9600);
  23. // Sound Detector Pin Assignment
  24. pinMode(PIN_LED_OUT, OUTPUT);
  25. pinMode(PIN_GATE_IN, INPUT);
  26. // Relay Pin Assignment
  27. pinMode(relay, OUTPUT);
  28. // Sound Decector Interrupt
  29. attachInterrupt(IRQ_GATE_IN, soundISR, CHANGE);
  30. }
  31. void loop()
  32. {
  33. // Read Sound
  34. val = analogRead(PIN_ANALOG_IN);
  35. // Testing
  36. Serial.println(val);
  37. // If Sound Exceeds X
  38. if (val > 55) {
  39. digitalWrite(relay, HIGH);
  40. delay(600);
  41. digitalWrite(relay, LOW);
  42. delay(200);
  43. } else {
  44. digitalWrite(relay, LOW);
  45. }
  46. delay(10);
  47. }