Arduino bluetooth home automation project

Hey everyone! I've been looking through the forums for a while now, and finally decided to sign up!

I'm doing a home automation project after falling in love with Arduino! I've created a android app (appinventor) to control a 8ch relay through bluetooth, which turns on or off lights etc, and it works great at this point!

However, I'm looking into adding the awesomeness of WS2812 RGB lights to all rooms, but I can't really figure out how to add it to the current code. I've also used these leds before to create ambilight on my tv through a arduino uno and processing and it looks great!

For example:
I would like to change/control all the WS2812 RGB lights individually, for example the livingroom light (as seen below in the code) to have a different color, brightness, pattern (like the FastLed examples).
Like how would you go about incorporating a existing FastLed example into the code below for each led light strip? So that I can send commands from the android app and activate it, just like I'm doing now with the relays.

I've tried searching, and looked a bit into some threads, like this one: http://forum.arduino.cc/index.php?topic=223286.0 but it's not fully clear to me. Can anyone point me in the right direction? Would appreciate it lots, sorry for not being all too familiar with all this, and sorry if I've missed an answer out somewhere in the forum.

This is a shorter version of my current code just to switch the relay's through bluetooth and a android device with the app:

#include "FastLED.h" //hmmm how to incorporate this..

String androidRead;
int 
//Relay control pins
livingRoomLight = 2,
kitchenLight = 3;
//--------------------------Call A Function-------------------------------//  
void allon(){
     digitalWrite(livingRoomLight, HIGH); 
     digitalWrite(kitchenLight, HIGH); 
}
void alloff(){
     digitalWrite(livingRoomLight, LOW); 
     digitalWrite(kitchenLight, LOW);
}

void setup() {
  Serial.begin(9600);
  pinMode(livingRoomLight, OUTPUT); 
  pinMode(kitchenLight, OUTPUT); 
}

void loop() {
  while (Serial.available()){  //Check if there is an available byte to read
  delay(10); //Delay added to make things stable 
  char c = Serial.read(); //Conduct a serial read
  if (c == '#') {break;} //Exit the loop when the # is detected after the word
  androidRead += c; //Shorthand for voice = voice + c
  }  
  if (androidRead.length() > 0) {
    Serial.println(androidRead); 
 
  //----------Control Multiple Pins/ LEDs----------//  
       if(androidRead == "*all on") {allon();}  //Turn Off All Pins (Call Function)
  else if(androidRead == "*all off"){alloff();} //Turn On  All Pins (Call Function)
  
  //----------Turn On One-By-One----------// 
  else if(androidRead == "*livingroom lights on") {digitalWrite(livingRoomLight, HIGH);} 
  else if(androidRead == "*kitchen lights on") {digitalWrite(kitchenLight, HIGH);}
  //----------Turn Off One-By-One----------// 
  else if(androidRead == "*livingroom lights off") {digitalWrite(livingRoomLight, LOW);} 
  else if(androidRead == "*kitchen lights off") {digitalWrite(kitchenLight, LOW);}

androidRead="";}} //Reset the variable after initiating
  androidRead += c; //Shorthand for voice = voice + c

No, it isn't.

So that I can send commands from the android app and activate it, just like I'm doing now with the relays.

If you can figure out how to all allon() or alloff() , why can't you figure out how to call a function what sets some or all of the LEDs the way you want?

PaulS:

  androidRead += c; //Shorthand for voice = voice + c

No, it isn't.
If you can figure out how to all allon() or alloff() , why can't you figure out how to call a function what sets some or all of the LEDs the way you want?

It is from a tutorial originally which I adapted to my relay setup.

Well, it's a bit confusing to me on the setup of all the leds datainput pins (specifically speaking of FastLed) and how to adapt different amounts of total leds for each led, in the same sketch, like stated in the examples of fastled (#define num_leds) etc.

I wouldn't have asked if I knew how exactly.
But I'll try and research some more, just too new to this

how to adapt different amounts of total leds for each led

How can an LED have different amounts of LEDs?

It is from a tutorial originally which I adapted to my relay setup.

If you don't understand the comment, it is not useful. Useless comments do not deserve to live.

Give an example of the FastLED code you are trying to incorporate.

PaulS:
How can an LED have different amounts of LEDs?
If you don’t understand the comment, it is not useful. Useless comments do not deserve to live.

Give an example of the FastLED code you are trying to incorporate.

Yes sir, you are correct, although it’s probably a mistake from my side

Pardon me, what I meant was that each led strip had different amount of leds, for instance living room table light has for ex. 60 total leds, while kitchen has 80 total leds etc. etc.

I was looking a bit more into the FastLed wiki, and found this other code as an example which pretty much almost does what I intend to, however what I want is a different #define NUM_LEDS_PER_STRIP 60 per strip, would I simply duplicate this several times, rename and adapt to each strip in the Setup section? And as for the code I had in the first post, would I simply create a similar allon() or alloff() and call for this function? hmm such questions, I won’t be able to test it until tomorrow.

Thank you for your replies!

// ArrayOfLedArrays - see https://github.com/FastLED/FastLED/wiki/Multiple-Controller-Examples for more info on
// using multiple controllers.  In this example, we're going to set up four NEOPIXEL strips on three
// different pins, each strip getting its own CRGB array to be played with, only this time they're going
// to be all parts of an array of arrays.

#include "FastLED.h"

#define NUM_STRIPS 3
#define NUM_LEDS_PER_STRIP 60 //can this simply be duplicated?
CRGB leds[NUM_STRIPS][NUM_LEDS_PER_STRIP];

// For mirroring strips, all the "special" stuff happens just in setup.  We
// just addLeds multiple times, once for each strip
void setup() {
  // tell FastLED there's 60 NEOPIXEL leds on pin 10
  FastLED.addLeds<NEOPIXEL, 10>(leds[0], NUM_LEDS_PER_STRIP);

  // tell FastLED there's 60 NEOPIXEL leds on pin 11
  FastLED.addLeds<NEOPIXEL, 11>(leds[1], NUM_LEDS_PER_STRIP);

  // tell FastLED there's 60 NEOPIXEL leds on pin 12
  FastLED.addLeds<NEOPIXEL, 12>(leds[2], NUM_LEDS_PER_STRIP);

}

void loop() {
  // This outer loop will go over each strip, one at a time
  for(int x = 0; x < NUM_STRIPS; x++) {
    // This inner loop will go over each led in the current strip, one at a time
    for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
      leds[x][i] = CRGB::Red;
      FastLED.show();
      leds[x][i] = CRGB::Black;
      delay(100);
    }
  }
}
#define NUM_LEDS_PER_STRIP 60 //can this simply be duplicated?

Suppose that name was MAX_LEDS_PER_STRIP. Would what the code is doing make more sense? Would you see that you are actually able to use fewer LEDs for one strip than another?

PaulS:

#define NUM_LEDS_PER_STRIP 60 //can this simply be duplicated?

Suppose that name was MAX_LEDS_PER_STRIP. Would what the code is doing make more sense? Would you see that you are actually able to use fewer LEDs for one strip than another?

Yes, that is true, makes perfect sense, I think I have it kinda figured it out overall, and I now have a sketch that compiles, where I can call for functions to change colors on different led strips on different pins, will try it later and see

Thanks again for your input, I'll let you know if I bump into any issues