Advertisement
Guest User

Code - LED Strip - Dim on noise

a guest
Nov 24th, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #define LEDstrip
  2.  
  3. void setup()
  4. {
  5. pinMode(A1,INPUT); //SparkFun Electret Microphone Breakout connected to Analog Pin 7
  6. pinMode(13, OUTPUT);
  7. pinMode(12, OUTPUT);
  8. pinMode(11, OUTPUT);
  9.  
  10. }
  11.  
  12. //this function will make the LED dim once the SparkFun Electret Microphone Breakout sends a 1 signal, and then returns to to recorded brightness.
  13. void loop()
  14. {
  15. boolean soundstate = digitalRead(A1);
  16. if (soundstate == 1) {
  17. analogWrite(11, 188);
  18. analogWrite(12, 255);
  19. analogWrite(13, 255);
  20.  
  21. delay(10);
  22. }
  23. else{
  24.  
  25. analogWrite(11,0);
  26. analogWrite(12,0);
  27. analogWrite(13,0);
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement