I have made the neopixels adjust their brightness to music, using a sparkfun sound detector.
However I cannot work out how to change the colour as well. E.G if the sound detector detects a loud beat then the neopixels go red.
My thinking was to use a if statement to check if the sound value is greater than a certain amount, then set the colours. Red = 255, Green = 0 and Blue = 0.
I think due to the for loop I am using, this mucks it up, I've tried everything I can think of but each time they all just go off.
Here is my code :
#define PIN_GATE_IN 2
#define IRQ_GATE_IN 0
#define PIN_LED_OUT 13
#define PIN_ANALOG_IN A0
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN 6
Adafruit_NeoPixel strip = Adafruit_NeoPixel(15, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(PIN_GATE_IN, INPUT);
#if defined (__AVR_ATtiny85__)
if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
strip.begin();
strip.show();
}
void loop() {
int green = 0;
int red = 0;
int blue = 0;
int x;
int value;
int n = 1;
int intensity;
value = analogRead(PIN_ANALOG_IN);
intensity = map(value, 0, 500, 0, 64);
for (x = 1; x < 15; x++) {
red = 255;
green = 255;
blue = 0;
strip.setPixelColor(n, red, green, blue);
strip.show();
n = n+1;
strip.setBrightness(intensity); }
}
This is without attempting the if statements