Last active
May 18, 2018 10:58
-
-
Save sruli/107216c1aff5bea33d4dc1c7812e0ee4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <FastLED.h> | |
#define NUM_LEDS 10 | |
#define LED_PIN 9 | |
#define LED_TYPE WS2811 | |
CRGB led[NUM_LEDS]; | |
void setup() | |
{ | |
Serial.begin(9600); | |
pinMode(7,INPUT); //SIG of the Parallax Sound Impact Sensor connected to Digital Pin 7 | |
FastLED.addLeds<LED_TYPE, LED_PIN>(led, NUM_LEDS); | |
for (int i = 0; i < NUM_LEDS; i++) { | |
led[i] = CRGB(0, 0, 0); | |
} | |
FastLED.show(); | |
} | |
//this function will make the LED dim once the Parallax Sound Impact Sensor sends a 1 signal, and then return to it’s original brightness. | |
void loop() | |
{ | |
boolean soundstate = digitalRead(7); | |
Serial.print(soundstate); | |
Serial.print("\n"); | |
if (soundstate == 1) { | |
setBlue(255); | |
} | |
else{ | |
setBlue(0); | |
} | |
} | |
void setBlue(int val) { | |
for (int i = 0; i < NUM_LEDS; i++) { | |
led[i] = CRGB(0, 0, val); | |
} | |
FastLED.show(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment