RGB Led STRIP Control Android APP – SMD5050

RGB Led STRIP Control Android APP
Hello world! Today i made a RGB led strip control with arduino and android, the app i had already made but this code is different then my previous RGB control which only controls a single RGB Led. For the strip i needed to modify the code a little bit, if you have inverted colors go to the bottom of the code and follow the instructions there. Go to the next step for the Schematic, code and parts list.

RGB Led STRIP Control Android APP

If you have problems with inverted colors uncomment line 76 to 78.
// analogWrite(PIN_RED, (R.toInt()));//if colors are inverted uncomment this part
// analogWrite(PIN_GREEN, (G.toInt()));//and comment below part.
// analogWrite(PIN_BLUE, (B.toInt()));
and comment line 80 tot 82.
analogWrite(PIN_RED, (255-R.toInt()));//comment if colors are inverted
analogWrite(PIN_GREEN, (255-G.toInt()));//and uncomment above part.
analogWrite(PIN_BLUE, (255-B.toInt()));

Schematic:
RGB Led STRIP Control Android APP
Wire the RGB Led amplifier to the arduino, Attach the led strip to the Led amplifier as seen on the schematic, Plug in a 12v Led strip adapter and upload the code.

Check this post to find out how to change the HC-06 Name, Baudrate, PIN and more about the hc-05 / hc-06 AT commands.

Parts list:
Arduino uno.
RGB Led Amplifier
RGB Led strip (SMD5050) You can buy these anywhere.
Jumper wire set MM/FF/MF
The Android APP & android phone

Good luck!

Code:

//author: Danny van den Brande, Arduinosensors.nl. Bluecore tech.
//Led control, I used a SMD 5050 Led strip.
#include <SoftwareSerial.h>
#include <Wire.h>
SoftwareSerial mySerial(10,11); //Define PIN11 & PIN12 as RX and TX pins

int PIN_RED = 3;
int PIN_GREEN = 5;
int PIN_BLUE = 9;

String RGB = ""; 
String RGB_Previous = "255.255.255"; 
String ON = "ON"; 
String OFF = "OFF"; 
boolean RGB_Completed = false;
 
void setup() {
  pinMode (PIN_RED, OUTPUT);
  pinMode (PIN_GREEN, OUTPUT);
  pinMode (PIN_BLUE, OUTPUT);
  Serial.begin(9600); 
  mySerial.begin(9600);
  RGB.reserve(30);
}
 
void loop() {

  while(mySerial.available()){
    char ReadChar = (char)mySerial.read();
 
    if(ReadChar == ')'){
      RGB_Completed = true;
    }else{
       RGB += ReadChar;
    }
  }
  
  if(RGB_Completed){
 
      Serial.print("RGB:");
      Serial.print(RGB);
      Serial.print("     PreRGB:");
      Serial.println(RGB_Previous);
      
      if(RGB==ON){
          RGB = RGB_Previous; 
          Light_RGB_LED();
      }else if(RGB==OFF){
          RGB = "0.0.0"; 
          Light_RGB_LED();
      }else{
          Light_RGB_LED();   
          RGB_Previous = RGB;     
      }
      RGB = "";
      RGB_Completed = false;      
  } 
} 
 
void Light_RGB_LED(){
 
  int SP1 = RGB.indexOf(' ');
  int SP2 = RGB.indexOf(' ', SP1+1);
  int SP3 = RGB.indexOf(' ', SP2+1);
  String R = RGB.substring(0, SP1);
  String G = RGB.substring(SP1+1, SP2);
  String B = RGB.substring(SP2+1, SP3);

  Serial.print("R=");
  Serial.println( constrain(R.toInt(),0,255));
  Serial.print("G=");
  Serial.println(constrain(G.toInt(),0,255));
  Serial.print("B=");
  Serial.println( constrain(B.toInt(),0,255));
 
//  analogWrite(PIN_RED,  (R.toInt()));//if colors are inverted uncomment this part
//  analogWrite(PIN_GREEN, (G.toInt()));//and comment below part.
//  analogWrite(PIN_BLUE,  (B.toInt()));

  analogWrite(PIN_RED,  (255-R.toInt()));//comment if colors are inverted
  analogWrite(PIN_GREEN, (255-G.toInt()));//and uncomment above part.
  analogWrite(PIN_BLUE,  (255-B.toInt()));
 
}
Danny van den Brande

http://www.arduinosensors.nl

Programmer, Game Designer, 3D Designer, Web Designer, Graphic Designer. Jup this website looks crappy.. :) But enjoy the projects! Everything you need is here.

Leave a Reply

Your email address will not be published. Required fields are marked *