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._
_ }_
_ }}*_
deftest.ino (1.91 KB)