Go Down

Topic: LED strip doesn't blink when using HC-05 (Read 593 times) previous topic - next topic

JTORFS

Hi everyone,


My LED-strip is fading in and out as it should, but when I try it with my smartphone via the HC-05 bluetooth module, the LED's are not fading anymore. They're just on. How can I solve this?

The code:



#include <SoftwareSerial.h>             // bibliotheken voor bluetooth
SoftwareSerial BTserial(10, 11);        // RX en TX toewijzen

 
#include <FastLED.h>
#define NUM_LEDS 6  // # of LEDS in the strip
CRGB leds[NUM_LEDS];
#define DATA_PIN 6 // Output Pin to Data Line on Strip

int fadeAmount = 5;  // Set the amount to fade I usually do 5, 10, 15, 20, 25 etc even up to 255.
int brightness = 0;


void setup()
{
    BTserial.begin(9600);               //synchronisatiesnelheid bluetooth op 9600 baud
    Serial.begin(9600);                 // synchronisatie naar de seriĆ«le monitor op 9600 baud
   
    FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
   
     // initialize the pushbutton pin as an input:
 }

void loop()
{

 if(BTserial.available())
  {
  char data=BTserial.read();          //lees de data binnen als ASCII (karakter)
  Serial.println(data);               // print naar de serial monitor

                   
 if(data=='x')                       
    {
     for(int i = 0; i < NUM_LEDS; i++ )       
        {
          leds.setRGB(255,0,0);  // setRGB functions works by setting
                                     // (RED value 0-255, GREEN value 0-255, BLUE value 0-255)
                                     // RED = setRGB(255,0,0)
                                     // GREEN = setRGB(0,255,0)
          leds.fadeLightBy(brightness);
          }
          BTserial.println("Fade");
          Serial.println("Fade");
            BTserial.print(";");
          FastLED.show();
          brightness = brightness + fadeAmount;
          // reverse the direction of the fading at the ends of the fade:
          if(brightness == 0 || brightness == 255)
          {
            fadeAmount = -fadeAmount ;
          }   
          delay(5);  // This delay sets speed of the fade. I usually do from 5-75 but you can always go higher.
        }
        }}
       
   

JTORFS

Nevermind y'all! Got it solved already :D

Go Up