RGB Bluetooth Light Control with App

Video shows earlier development of the project where it only had an single LED. The project was later improved to work with 5050 RGB programable neo pixel strip with minor changes. This project took only few days and I was extremely inexperienced back in 2017. 

Bluetooth controlled RGB light using the arduino Bluetooth module and custom app. The app was made using google MIT app inventor 2, the APK file will be available for download in the post.

 

/*
* LED / RGB Strip Control via Bluetooth HC-06
* by Masum Ahmed (Ma786), ma786@kent.ac.uk
*
*/

#include 
#define PIN 10 //RGB strip
#define N_LEDS 8 //number of led
#define led 11 // test led

int x = N_LEDS - 1;
long state;
long brightness;
int rgbR = 5;
int rgbG = 5;
int rgbB = 5;
boolean powerON = false;

Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_LEDS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
strip.begin();
strip.show();
pinMode(led, OUTPUT);
Serial.begin(9600);
}

void loop() {
while (Serial.available()) {
state = Serial.parseInt();
//Serial.println(state);
setValues();
RGBstrip();
ledControl();
}
}

void setValues() {
switch (state) {
case 1:
powerON = true;
break;
case 2:
powerON = false;
break;
case 3: //brightness
brightness = Serial.read();
//Serial.println(brightness);
break;
case 4: //green
rgbG = Serial.read();
//Serial.println(rgbG);
break;
case 5: //red
rgbR = Serial.read();
//Serial.println(rgbR);
break;
case 6: //blue
rgbB = Serial.read();
// Serial.println(rgbB);
break;
default:
break;
}
}

void RGBstrip () {
strip.setBrightness(brightness);
for (int i = 0; i < x; i++) {
strip.setPixelColor(i, rgbR, rgbG, rgbB); //rgb value red green blue
}
strip.show();
}

void ledControl() {
if (powerON) {
digitalWrite(led, HIGH);
}
if (!powerON) {
digitalWrite(led, LOW);
}
}