Components
Will give the approximate cost of all the components that were used in the work. Most components are bought in stores of my town so bring everything in rubles.
Prototype
Debug firmware for Arduino, like everyone, I made on the breadboard using conventional LEDs.
Scheme
With the help of the notorious environment for designing Eagle CAD was modified scheme of the author and the printed circuit Board. Here I added a voltage regulator To 5 volts, changed the sensors with 3 pins expensive Ping on four contact cheap HC-SR04. In order that the illumination of the stairs worked only in the dark, is added to the schema of the Soviet photoresistor FR-764 (you can use another).
The sketch
The sketch uses a freely distributable library for working with led driver M5450 and library to work with an ultrasonic range finder HC-SR04.
#include “lightuino3.h” #include “Ultrasonic.h”
//Set the pins to the first sensor #define TRIG_PIN 12 #define ECHO_PIN 13 //Set the pins for the second sensor #define TRIG2_PIN 10 #define ECHO2_PIN 11 //Define the first sensor Ultrasonic OurModuleUp(TRIG_PIN, ECHO_PIN); //Define the second sensor Ultrasonic OurModuleDown(TRIG2_PIN, ECHO2_PIN); // pins 0, 1 used by Serial const unsigned char DataPin = 6; const unsigned char clockPin = 7;
// delay between steps const long lightSpacing = 280; //delay illumination of the stairs const long lightHold = 10000; //shot delay sensor const long pingReadDelay = 50;
// Range at which the work sensor const float minBottomIn = 33.0 f; const float minTopIn = minBottomIn;
LightuinoSink sinks(clockPin, DataPin, 100, 4);
bClimbStarted boolean = false; bDescentStarted boolean = false;
int val; void setup() { Serial.begin(9600); pinMode(DataPin, OUTPUT); pinMode(clockPin, OUTPUT); delay(1000); sinks.set(0,0,0); }
void loop() { val = analogRead(0); //Check the lighting in the room if (val>=1020){
UltrasonicDownFire();//the Shot, the lower sensor if(bClimbStarted) { bClimbStarted = false; bDescentStarted = false; climbLightSequence(); } else { // Shot upper sensor UltrasonicUpFire(); if(bDescentStarted) { bClimbStarted = false; bDescentStarted = false; descentLightSequence(); } } delay(pingReadDelay); } }
//Top sensor void UltrasonicUpFire() {
if((OurModuleUp.Ranging(INC) < minTopIn) && (OurModuleUp.Ranging(INC) > 0)) { Serial.println(“Top sensor tripped.”); bDescentStarted = true; } }
//Handling the lower sensor] void UltrasonicDownFire() {
if((OurModuleDown.Ranging(INC) < minTopIn) && (OurModuleDown.Ranging(INC) > 0)) { Serial.println(“Bottom sensor tripped.”); bClimbStarted = true; } }
void climbLightSequence(){ LedsOnDown(); } void LedsOnDown(){ //Reset byte ledState[9]; for (int j=0;j=0;k–) { for (int j=8;j>=1;j–) { ledState[k] = (ledState[k] >> 1) + 128; sinks.set(ledState); delay(lightSpacing); } } //Delay delay(lightHold); //Extinguish for (int k=1;k>=0;k–) { for (int j=8;j>=1;j–) { ledState[k] = (ledState[k] >> 1); sinks.set(ledState); delay(lightSpacing); } } delay(pingReadDelay); }
void descentLightSequence(){ LedsOnUp(); }
void LedsOnUp(){ //Reset byte ledState[9]; for (int j=0;j ledState[j] = B00000000; } //Light for (int k=0;k { for (int j=0;j { ledState[k]=(ledState[k] << 1) + 1; sinks.set(ledState); delay(lightSpacing); } } delay(lightHold); for (int k=0;k { for (int j=0;j { ledState[k]=(ledState[k] << 1); sinks.set(ledState); delay(lightSpacing); } } delay(pingReadDelay); }
A little about installation
Since I have the most simple wooden ladder (without podstupenej Board), mount the led strips was carried out from the end of each step.
Is through the length of the cable channel with the laid wires, which are glued with liquid nails. Led strips have the adhesive side, they stay on the tree.
The sensors were installed at the beginning of each of the first stage at the top and bottom of the stairs. As mount used conventional escutcheon for drywall.
From the housing of the power supply alarms have been thrown a dead battery, place it easily fit our controller.
The cover is in place. Place the controller under the landing.
The result
Actually the video does not reflect the real picture. Ladder covers are much prettier and brighter.
VIDEO
Recommend to read FLYING CRUISER K-7 K-7 is a Soviet multi-purpose aircraft pilot-giant design Bureau K. A. Kalinin. Was developed in the early 1930-ies, using original engineering solutions, new technologies and materials.... IN THE CLOUDLESS SKY OF SPAIN The fighter I-16 in the civil war of Spain. The history of the airplane. This plane was largely first. In the USSR, he was the first popular fighter with retractable landing gear, the...