ardutronic
Published © CC BY-NC-SA

Stair Lights - DIY, RGB, Automatic

This article will be a bit about electronics, soldering, 3d printing, PCB, all thanks to my new project, automatic stair lights.

IntermediateFull instructions provided5 hours1,716
Stair Lights - DIY, RGB, Automatic

Things used in this project

Hardware components

ESP8266 ESP-12E
Espressif ESP8266 ESP-12E
×1
WS2812 Addressable LED Strip
Digilent WS2812 Addressable LED Strip
×1
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Custom parts and enclosures

PCB Case

PCB Case 2

Case 1

Case 2

Schematics

BRD

SCH

Code

Code

Arduino
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "your blynk auth";
#include <Adafruit_NeoPixel.h> 
Adafruit_NeoPixel linijka = Adafruit_NeoPixel(150, 10, NEO_GRB + NEO_KHZ800);
//#define trigPin1 13
//#define echoPin1 12
//#define trigPin1 5
//#define echoPin1 4

int red = 10;
int green = 10;
int blue = 10;


int red1 = 10;
int green1 = 10;
int blue1 = 10;


int r;
int g;
int b;

int a = 0;
int pir1 = 12;
int pir2 = 14;
int rpir1;
int rpir2;
int i;
int przycisk;
//int zmierzOdleglosc1;
//int zmierzOdleglosc2;

void setup() {
  linijka.begin(); 
  linijka.show();
  Blynk.begin(auth, "wifi", "pass");
  pinMode(pir1, INPUT);
  pinMode(pir2, INPUT);

  //  pinMode(trigPin1, OUTPUT); 
  // pinMode(echoPin1, INPUT); 
  // pinMode(trigPin2, OUTPUT); 
  //  pinMode(echoPin2, INPUT);
}

/*void zmierzOdleglosc11() {
  long czas, dystans;

  digitalWrite(trigPin1, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin1, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin1, LOW);

  czas = pulseIn(echoPin1, HIGH);
  dystans = czas / 58;

  zmierzOdleglosc1 = dystans;
  }
  /*
  void zmierzOdleglosc22() {
  long czas, dystans;

  digitalWrite(trigPin2, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin2, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin2, LOW);

  czas = pulseIn(echoPin2, HIGH);
  dystans = czas / 58;

  zmierzOdleglosc2 = dystans;
  }
*/
BLYNK_WRITE(V0) 
{
  r = param[0].asInt();
  g = param[1].asInt();
  b = param[2].asInt();
}

BLYNK_READ(V1) 
{
  Blynk.virtualWrite(V1, rpir1); 
}


BLYNK_READ(V2) 
{
  Blynk.virtualWrite(V2, rpir2);
}

BLYNK_WRITE(V4) 
{
  przycisk = param.asInt();
}

void loop() {
  Blynk.run();
  rpir1 = digitalRead(pir1);
  rpir2 = digitalRead(pir2);

    if (rpir1 == 0 && rpir2 == 0)
    {
      if (a == 0)
      {
        clearLed();
        a = 1;
      }
    }

    if (rpir1 == 1 && rpir2 == 0)
    {
      mode2();
      delay(2000);
      a = 0;
    }

    if (rpir1 == 0 && rpir2 == 1)
    {
      mode1();
      delay(2000);
      a = 0;
    }

}

void clearLed()
{
  i = 0;

  for (i = 0; i <= 150; i++) {
    linijka.setPixelColor(i, linijka.Color(0, 0, 0));
    linijka.show();
    delayMicroseconds(10);
  }
}

void mode1()
{
  i = 0;
  for (i = 0; i <= 150; i++) {
    linijka.setPixelColor(i, linijka.Color(r, g, b));
    linijka.show();
    delay(35);
  }
}
void mode2()
{
  i = 150;
  for (i = 150; i >= 0; i--) {
    linijka.setPixelColor(i, linijka.Color(r, g, b)); 
    linijka.show();
    delay(35);
  }
}

void fade()
{
  red1 = 0;
  blue1 = 0;
  green1 = 0;
  for (i = 150; i >= 0; i--) {
    linijka.setPixelColor(i, linijka.Color(red1++, green1++, blue1++)); 
    linijka.show();
    delayMicroseconds(2);
  }
  i = 150;
}

void blynkrgb()
{
  i = 150;
  for (i = 150; i >= 0; i--) {
    linijka.setPixelColor(i, linijka.Color(r, g, b)); 
    linijka.show();
    delayMicroseconds(2);
  }
}

Credits

ardutronic

ardutronic

39 projects • 37 followers
I'm 20 years old student of electronic technical college. I'm passionate about electronics as well as editing movies

Comments