ashish_8284
Published

Making Smart LED Strip From Boring IR Controller LED Strip

I tried to convert IR remote controlled RGB LED strip in to smart LED strip. Hard ware used ESP01.

IntermediateWork in progress8 hours7,106
Making Smart LED Strip From Boring IR Controller LED Strip

Things used in this project

Hardware components

ESP8266 ESP-01
Espressif ESP8266 ESP-01
×1
PC817
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Final Schematic

Final Schematic of Smart LED making

Code

Smart LED strip Trial Code

Arduino
This code is used to check RGB LED strip controlling using web page.
Kindly comment Line number 36 to 40 in setup.
#include <ESP8266WiFi.h>
#include <WiFiClient.h> 
#include <ESP8266WebServer.h>

//WIFI AP Definetion
const char *myssid = "Smart_LED_Strip";
const char *password = "XXXXXXX"; //Put your prefered password
IPAddress ip(192,168,11,4);
IPAddress gateway(192,168,11,1);
IPAddress subnet(255,255,255,0);

//WIFI Client definetion Not necessary for this project
const char *ssid = "XXXXXXX"; //Wifie router IP "i used this for MQTT server connecterion which will used in future
IPAddress station_ip;

//Webserver
ESP8266WebServer server(80);

//RGB calculation variables
int Rbri,Gbri,Bbri,Totalbri,Robri,Gobri,Bobri;

//Pin defination
int Rled = 1;
int Gled = 3;
int Bled = 2;

void setup() {    
//Pin setup
  pinMode(Rled,OUTPUT);
  pinMode(Gled,OUTPUT);
  pinMode(Bled,OUTPUT);
  WiFi.mode(WIFI_AP_STA); 
  server.on("/", handleRoot);
  server.begin();
//not advise to use if GPIO 1 & 3 is used as Output as it will conflict with RX TX functionality.  
  /*
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  */
//Initialised WIFI AP  
  WiFi.softAPConfig(ip, gateway, subnet);
  WiFi.softAP(myssid, password);
  station_ip = WiFi.localIP();
}
void loop() {
   server.handleClient();
   int rpwm = map(Robri,0,100,0,1024);
   int gpwm = map(Gobri,0,100,0,1024);
   int bpwm = map(Bobri,0,100,0,1024);
   analogWrite(Rled,rpwm);
   analogWrite(Gled,gpwm);
   analogWrite(Bled,bpwm);
   
//not advise to use if GPIO 1 & 3 is used as Output as it will conflict with RX TX functionality.  
  /*
   Serial.print("R led pwm- ");Serial.println(rpwm);
   Serial.print("G led pwm- ");Serial.println(gpwm);
   Serial.print("B led pwm- ");Serial.println(bpwm);
   */
}

// Wepage 
void handleRoot() {
int on_time,off_time;
   char temp[1500];
   snprintf ( temp, 1000,
"<html>\
  <head>\
    <title>Techno Automation</title>\
    <style>\
      body { background-color: #cccccc; font-family: Arial, Helvetica, Sans-Serif; Color: #000088; }\
            .button {background-color: #990033; border: none; color: white; padding: 7px 15px;text-align: center; cursor: pointer;}\
    </style>\
  </head>\
  <body>\
    <h1>Smart LED Strip controller</h1>\
    <p>AP IP address = %02d.%02d.%02d.%02d</p>\
    <p>Station IP address = %02d.%02d.%02d.%02d</p>\
    <p>R:G:B:Bri= %02d:%02d:%02d:%02d:</p>\
    <form action='http://192.168.11.4' method='POST'>\
    Red: <input type='text' name='Red'>Percentage\<br>\
    Green: <input type='text' name='Green'>Percentage\<br>\
    Blue: <input type='text' name='Blue'>Percentage\<br>\
    Brightness: <input type='text' name='Brightness'>Percentage\<br>\
    <input type='submit' class = button value='Submit'>\<br>\  
    Refresh Page After Submit setting\<br>\
  </form>\
  </body>\
</html>",
    station_ip[0],station_ip[1],station_ip[2],station_ip[3],ip[0],ip[1],ip[2],ip[3],Rbri,Gbri,Bbri,Totalbri
   );
server.send(200, "text/html", temp);

//Sending Webpage submitted value to calculation.
Get_String(String(server.arg("Red")),String(server.arg("Green")),String(server.arg("Blue")),String(server.arg("Brightness")));
}
//In Below function all calculationis carried out.
void Get_String(String R,String G,String B,String Bri){
    int a,b,c,d;
    a = R.toInt();
    b = G.toInt();
    c = B.toInt();
    d = Bri.toInt();
    //Serial.print(a);Serial.print(",");    Serial.print(b);Serial.print(",");    Serial.print(c);Serial.print(",");    Serial.println(d);
    if(d>0) Totalbri = constrain(d,0,100);
    if(a>0) Rbri = constrain(a,0,100); 
    if(b>0) Gbri = constrain(b,0,100);
    if(c>0) Bbri = constrain(c,0,100);
        /*
        Serial.print("R:- ");
        Serial.println(Rbri);
        Serial.print("G:- ");
        Serial.println(Gbri);
        Serial.print("B:- ");
        Serial.println(Bbri);
        Serial.print("Brightness:- ");
        Serial.println(Totalbri)
        ;
        */
    Robri = Rbri*Totalbri/100;
    Gobri = Gbri*Totalbri/100;
    Bobri = Bbri*Totalbri/100;
        /*
        Serial.print("Ro:- ");
        Serial.println(Robri);
        Serial.print("Go:- ");
        Serial.println(Gobri);
        Serial.print("Bo:- ");
        Serial.println(Bobri);
        Serial.print("Brightness:- ");
        Serial.println(Totalbri);
        */    
}

Credits

ashish_8284

ashish_8284

10 projects • 34 followers

Comments