hi im looking for some help with bluetooth and fast led library. I have been trying to get my head around brightness control for the last few day with an arduino uno, hc-05 bluetooth module, the fast led library and im using bluetooth electronics app. I can turn on and off the ws2812 and other simple things but cant get brightness slider to work when i try to use the slider in the app it just reset the ws2812 off state. i tryed a premade sketch by the bluethooth app and the brightness controled work with the ws2812 but the premade skecth is not using the fast led library
#include <FastLED.h>
#define NUM_LEDS 5
#define DATA_PIN 8
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
#define MAX_BRIGHTNESS 155
#define MIN_BRIGHTNESS 32
char state;
int max_bright;
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
Serial.begin(9600);
}
void loop() {
if(Serial.available() >0){
state = Serial.read();
if(state=='A');
if(state=='a');
if(state=='B');
if(state=='b');
if(state=='N');
if(state=='n');
if(state=='R') max_bright-Serial.parseInt();
int max_bright = map(analogRead(state), 0, 500, 0, 255);
FastLED.setBrightness(constrain(max_bright, MIN_BRIGHTNESS, MAX_BRIGHTNESS));
}
if(state=='a')
{
leds[0] = CRGB( 50, 100, 150);
leds[1] = CRGB( 176, 244, 66);
leds[2] = CRGB( 146, 61, 153);
leds[3] = CRGB( 214, 42, 82);
leds[4] = CRGB( 193, 142, 32);
FastLED.show();
}
if(state=='b')
for(int dot = 0; dot < NUM_LEDS; dot++) {
leds[dot] = CRGB::Red;
FastLED.show();
// clear this led for the next time around the loop
leds[dot] = CRGB::Blue;
delay(70);
}
if (state=='B');
for(int dot = 0; dot < NUM_LEDS; dot++){
leds[dot] = CRGB::Black;
FastLED.show();
}
}