Arduino Forum

Using Arduino => LEDs and Multiplexing => Topic started by: TheAwakened99 on May 09, 2019, 06:20 pm

Title: Ws2812 not responding to input received from bluetooth
Post by: TheAwakened99 on May 09, 2019, 06:20 pm

I'm working on a project which requires me to switch on only particular LEDs via Bluetooth using an app, for this to work as I want it to the LEDs need to be turned off at the start and only switch on when a particular input is received from the app.
When I connect my phone to the Bluetooth and press the respective buttons responsible for sending data to the Arduino the LEDs do not respond to the data received

Here is my code
Code: [Select]

#include <FastLED.h>
#define NUM_LEDS 5    //no of leds
#define DATA_PIN 7
#define BRIGHTNESS 90             

//#define ledPin 7               //pin to which led is connected on arduino
int state = 0;                 //variable to store data coming from phone


void setup()
  FastLED.addLeds<WS2812, DATA_PIN, GRB>(leds, NUM_LEDS);                          //setup led strip
  pinMode(DATA_PIN, OUTPUT);                //set led pin as op for bluetooth
  //digitalWrite(ledPin, LOW);               //setting op as low
  Serial.begin(38400);                // Default communication rate of the Bluetooth module
  /*for(int i=0;i<NUM_LEDS;i++)
    leds[i] = CRGB::Black;;
void loop()
    if(Serial.available() > 0)            // Checks whether data is comming from the serial port
      state =;          // Reads the data from the serial port
        leds[0] = CRGB::Red;; 
        leds[1] = CRGB::Red;;   
        leds[2] = CRGB::Red;;
        leds[3] = CRGB::Red;;
        leds[4] = CRGB::Red;;
Title: Re: Ws2812 not responding to input received from bluetooth
Post by: Grumpy_Mike on May 10, 2019, 09:51 am
First check your led code works by opening up the serial monitor and setting it to the same speed as you do in the code. Then use your keyboard to input the numbers. They should work like you want. Do that before trying with Bluetooth.

You should not have started a new thread but continued your old one.