📜 ⬆️ ⬇️

Automatic staircase lighting

Good afternoon, dear readers, I would like to acquaint you with my version of the project of automatic illumination of the stairs based on the Arduino Pro Mini controller. Perhaps for someone this article will become the basis for their own projects, well, I will be pleased to read the strict criticism in the comments.

The purpose of the project: to mount the staircase lighting on the second floor under the following conditions.
  1. Automation works only in the dark.
  2. Each stair step is highlighted after turning on the previous one.
  3. Steps are highlighted from bottom to top and vice versa.
  4. There is a reserve of time completely illuminated stairs.

Preparation for installation


As a controller, I used the familiar Arduino Pro Mini.

First, about the stairs itself, the number of steps 11, width 550 mm. A total of 6 meters of LED strip is required (ordered 2 pieces of 5 meters 5050 SMD), with an IP67 degree of protection (i.e., protection against dust and water) so that you can wipe off the dust and not worry about whether you are under stress or damage the tape.

After connecting a 5 m LED strip, the current through it turned out to be only 2.5 A, that is, for a 6 m LED strip, a 36 W power supply unit is needed. The choice stopped on the Chinese power supply 12 V 8.3 A 100 watts. 100, of course, a lot, but it took 12 V for another project, so I connected to it.
')
As a power supply of the controller itself, as well as sensors (5 V power supply), I used a simple low voltage circuit with the help of a voltage regulator L7805CV and two ceramic capacitors 0.1 μF and 0.33 μF.

image

As sensors detecting movement, he stopped on the HC-SR04 ultrasonic sensors, since they emit a narrow beam of ultrasonic pulses and you can adjust the operating distance. Thus, it can be set to track the intersection of the pulse in the first and last stages. Going into the details of the characteristics, method of connection, the principle of the sensor does not see the point in the Internet a lot of information about them.

The question of measuring the illumination was solved, also, quite simply with the help of a voltage divider circuit, in which the Gl5516 photoresistor is used as a variable resistor.

Next, we consider the question of the number of contacts used 11 digital for the stages, 4 for two sensors and one analog for measuring illumination. A total of 15 digital, which does not give us the Arduino. Without thinking, I used a 74S595N microcircuit, or rather a cascade of two shift registers to increase the number of Arduino digital outputs.

After reading the literature and opinions of radio amateurs, he put a 0.1 μF ceramic capacitor on the 12th leg of the STcp of the first register, ostensibly to minimize noise when applying a “latching” pulse. When testing the cascade “on the table” by me, it really works better with a capacitor, especially when the power supply to the chips is first applied.

It’s one thing to connect a weak load to the Arduino, like an LED, and another to connect a piece of LED strip 500-550 mm long (the maximum current for the Arduino digital output is 40 mA). The ULN2003A microcircuit (Darlington assembly) turned out to be more accessible to me; the maximum current through one output of which is 0.5 A.

image

I want to note that the Echo contact of the second sensor comes to the 13th Arduino contact, on which the LED of the controller itself is located.

This was done specifically, for convenience, at the moment when the condition “is it dark enough for the start of sensor polling?” Is satisfied, the LED on the 13th contact starts flashing.

Plata painted in Sprint-Layout. He emphasized that the chips and the controller were removed, soldered the SCS-14 and 16 panels, and also the socket on the PBS 2 × 12 2.54 board. The only negative was to arch the legs of the 74S595N chips to the other side.

image

Drawing a sketch


When compiling the sketch, only one Ultrasonic library was used (for working with the HC-SR04 sensors) and it was possible to do without it. I had to tinker with bit operations, since it was necessary to load two bytes in a cascade of shift registers in a certain way (in the sketch itself I made intelligible explanations).

Sketch
// *** V1***
//
#include "Ultrasonic.h"

//
#define Trig_1 10 // .
#define Echo_1 11
#define Trig_2 12 // .
#define Echo_2 13
#define Ds 8 // Ds/SDI 75HC595N_1.
#define STcp 7 // STcp/RCLK 75HC595_1, 2.
#define SHcp 6 // SHcp/SRCLK 75HC595_1, 2.
#define LDR A0 // .

Ultrasonic Sensor_1(Trig_1, Echo_1); // .
Ultrasonic Sensor_2(Trig_2, Echo_2); // .

//
const int Limit = 100; // .
const float Min_Disrance = 50.0; /* ,
55 .*/

boolean Up_Sensor_Started = false; // .
boolean Down_Sensor_Started = false; // .

const int Read_Delay = 50; // .

unsigned int leds = 0; // .
const int N = 10; /* .
! 14- 2 .*/
const int T_Ladder = 3000; // .
const int T_Stair = 500; // .

void setup()
{
pinMode(Ds, OUTPUT);
pinMode(STcp, OUTPUT);
pinMode(SHcp, OUTPUT);
// Serial.begin(9600); // 9600 .
}

void loop()
{
int LDR_Value = analogRead(LDR); // .
// Serial.println(LDR_Value); // 0 1023.
if(LDR_Value < Limit) // " ?".
{
Down_Sensor(); // .
if(Down_Sensor_Started) // .
// , ...
{
Down_Sensor_Started = false; // .
Up_Sensor_Started = false;
Turing_Upward(); // .
}
else
// ...
{
Up_Sensor(); // ...
if(Up_Sensor_Started) // .
// , ...
{
Down_Sensor_Started = false; // .
Up_Sensor_Started = false;
Turing_Downward(); // .
}
}
delay(Read_Delay); // .
}
}

//
void Up_Sensor()
{
if((Sensor_1.Ranging(CM) < Min_Disrance) && (Sensor_1.Ranging(CM) > 0))
// , ...
{
Up_Sensor_Started = true; // .
}
}

//
void Down_Sensor()
{
if((Sensor_2.Ranging(CM) < Min_Disrance) && (Sensor_2.Ranging(CM) > 0))
// , ...
{
Down_Sensor_Started = true; // .
}
}

//
void updateShiftRegister()
{
digitalWrite(STcp, LOW); // .
byte First = lowByte(leds); /* ,
shiftOut 8 .*/
byte Second = highByte(leds);
shiftOut(Ds, SHcp, MSBFIRST, Second); // 1- .
shiftOut(Ds, SHcp, MSBFIRST, First); // 2- .
digitalWrite(STcp, HIGH); // .
}

//
void Turing_Upward()
{
for (int i = 0; i <= N; i++)
{
bitSet(leds, i); // N 1 ( HIGH).
updateShiftRegister(); // .
delay(T_Stair); // .
}
// Serial.println(leds, BIN); // .
delay(T_Ladder); // .
leds = 0; // .
updateShiftRegister(); // .
}

//
void Turing_Downward()
{
for (int i = N; i >= 0; i--)
{
bitSet(leds, i); // N 1 ( HIGH).
updateShiftRegister(); // .
delay(T_Stair); // .
}
delay(T_Ladder); // .
leds = 0; // .
updateShiftRegister(); // .
}


Installation Features


Now about the installation, to lay the LED strip, of course, it is better to create a profile specially for her, but its cost is quite high. I took the cable channel 12 × 12, cut off the excess stationery with a red-hot stationery knife, the following happened.

image

To hide the sensors HC-SR04, I found for them the size of the box IEK 20 mm.

image

The installation of the panel was also not difficult, since the installation of screw terminal blocks was planned in advance on the board.

image

Total


The resulting project has satisfied all the tasks, during the operation of the automation there were no failures, comments.

The only thing, in my opinion, could be to make the shield more compact and completely close it from other hands.



Equipment


Arduino Pro Mini Atmega 328 5 V 16 MHz Controllerone
Ultrasonic sensor HC-SR042
Power supply 12 V 8.3 A 100 Wone
LED strip 5050 SMD 5 m IP652
Chip 74NS595N2
IC ULN2003A2
PBS 1 × 40 2.54 socketone
MGSHV 0.75 wire
PUNP cable 2 × 2.5
Cable telephone ShTLP-4 0.12 × 7
Single pole 1 A circuit breakerone
Single-pole circuit breaker 10 Aone
Photoresistor Gl5516one
Voltage stabilizer L7805CVone
0.33 uF ceramic capacitorone
Ceramic condenser 0.1 microfarad2
10 kΩ resistorone
Socket for chip SCS-142
SCS-16 chip socket2
Distribution box IEK 20 mm2
Two-pin screw terminal13
Fiberglass 95 × 105 mm
Textolite
SRK terminal through passage12
Cable channel 12 × 12 × 2000
Cable channel 16 × 16 × 2000
Consumables (glue, glue Moment Crystal, solder, rosin, TAGS flux)
Fasteners (bolts, nuts, screws, dowels, clamps)

Thanks for paying attention.

Source: https://habr.com/ru/post/397315/


All Articles