Good afternoon everybody
As ya'll can guess I am new to Arduino and coding, withsome help with friends we created this code
What it is is basically Music reactive LED lights, running from Centre outwards:
I want to change the direction to run outward to Centre but we cannot figure it out, we thought using opposite symbols like changing all the "+" to "-" and ">" to "<" would work, but alas, no is doesn't work that way
anny suggestion would be very helpfull
The Code:
#include <FastLED.h>
int r=0;
int g=0;
int b=0;
#define LED_PIN 8
#define NUM_LEDS 100// Enter Number of LEDS
#define BRIGHTNESS 0
#define LED_MID_L 50
#define LED_MID_R 50
uint8_t hue = 0;
CRGB leds[NUM_LEDS];
CRGB led[NUM_LEDS];
int s=0;
int k=0;
void setup() {
FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
for (int i =50; i >= 0; i--)
{
leds[i] = CRGB ( r,g,b);
leds[100-i] = CRGB (r,g,b );
delay(0);
FastLED.show();
}
pinMode(A0,INPUT);
pinMode(A1,INPUT);
}
void loop(){
//Treble();
Bass();
}
void Bass(){
{
s=analogRead(A0);
if((s>=536)&&(s<=540))//High Freq 4
{
leds[LED_MID_L]=CHSV(hue + (LED_MID_L * 10), 255, 255); //RED
leds[LED_MID_R]=CHSV(hue + (LED_MID_R * 10), 255, 255);
FastLED.setBrightness(144);
delay(50);
}
else if((s>=541)&&(s<=545)) //Max Freq 5
{
leds[LED_MID_L]=CHSV(hue + (LED_MID_L * 10), 255, 255); //RED
leds[LED_MID_R]=CHSV(hue + (LED_MID_R * 10), 255, 255);
FastLED.setBrightness(180);
delay(75);
}
else if((s>=546)&&(s<=550)) //Max Freq* 6
{
leds[LED_MID_L]=CHSV(hue + (LED_MID_L * 10), 255, 255); //RED
leds[LED_MID_R]=CHSV(hue + (LED_MID_R * 10), 255, 255);
FastLED.setBrightness(216);
delay(100);
}
else if((s>=551)&&(s<=700)) //Max Freq** 7
{
leds[LED_MID_L]=CHSV(hue + (LED_MID_L * 10), 255, 255); //RED
leds[LED_MID_R]=CHSV(hue + (LED_MID_R * 10), 255, 255);
FastLED.setBrightness(255);
delay (125);
}
else if((s>=531)&&(s<=535)) //Mid Freq 3
{
leds[LED_MID_L]=CHSV(hue + (LED_MID_L * 10), 255, 255); //RED
leds[LED_MID_R]=CHSV(hue + (LED_MID_R * 10), 255, 255);
FastLED.setBrightness(108);
delay(30);
}
else if((s>=526)&&(s<=530)) //Low Freq 2
{
leds[LED_MID_L]=CHSV(hue + (LED_MID_L * 10), 255, 255); //RED
leds[LED_MID_R]=CHSV(hue + (LED_MID_R * 10), 255, 255);
FastLED.setBrightness(72);
delay(20);
}
else if((s>=495)&&(s<=525)) //Very Low Freq 1
{
leds[LED_MID_L]=CHSV(hue + (LED_MID_L * 10), 255, 255); //RED
leds[LED_MID_R]=CHSV(hue + (LED_MID_R * 10), 255, 255);
FastLED.setBrightness(36);
delay(0);
fadeToBlackBy( leds, NUM_LEDS, 1);
}
else
{
leds[LED_MID_L] = CRGB ( r,g,b);
leds[LED_MID_R] = CRGB ( r,g,b);
}
for (int i = 0; i <= 50; i++)
{
leds[i] = leds[i+1];
leds[100-i] = leds[99-i];
}
EVERY_N_MILLISECONDS(65){
hue++;
}
FastLED.show();
}
}