📜 ⬆️ ⬇️

Smart Plinth 1.0



One problem affected me - a dark corridor on the way from the bedroom to the kitchen. Well, you know, I like to go to the kitchen at night, but in the dark it’s uncomfortable, but because Since the corridor is relatively long relative to the width, then there is a high probability of deviation from the route when oriented along the gyros built into the head. Error accumulates, and even legs of different lengths, walked with arms outstretched and fell into the doorway not the first time.
Yes, of course there are all kinds of night lights, motion sensors, smart homes, but I have better, I have a plastic baseboard with a cable channel.
Therefore, there was an idea to push the LED strip there and see how it will feel there and it turned out, you know, pretty cool, such a backlight, like in space ships.




Well, then of course - ARDUINO! And what for? And so Smart! I ordered 2 motion sensors on Ali and the work went.
')


Not work of course, but fun. The motion sensor was selected without fitting and I, as always lucky, it ideally suited to the baseboard. It took two sensors to put them on the two ends of the plinth, because you also have to return from the kitchen.




For some reason, the Chinese did the pinout of the sensor under the lens. The supply voltage range is 4.5–20V, output: 3.3V - there is movement, 0V - there is no movement. There is another jumper and two podstrochnik, did not begin to understand, because by default everything worked fine. Still, when I collected everything and paralleled 2 sensor outputs, the voltage, when moving, was about 1.5V. I think that it is impossible to do this and it was necessary to install the diodes, but it was reluctant to disassemble again, especially since this output was wound up on the ADC.



The tape is controlled by fieldwork IRFZ34N, because such a roll. Of course, it does not open fully with five volts, but with my tape, which consumes about 1A at 12V, it can cope without heating.



The photoresistor was taken cheap, Chinese.
The program is simple, with this logic: if the illumination is below a certain threshold, then we highlight, turn it on smoothly and turn it off after a set time. If during the glow again spotted movement, consider the delay again. Illumination is not measured when we shine, because light sensor illuminated by the baseboard.

int ledPin = 5;            // 
int lightSensorPin = A7;   //
int motionSensorPin = A0;  // 
int val = 0;               // 
int light = 0;             //
int motion = 0;            //
int timerCounter = 0;      // 
int timerEnable = false;   //  
int timeOn = 8;            //   
int faderEnable = false;   // 
int lightEnable = false;   // 

void setup()
{
    pinMode(ledPin, OUTPUT);      
    Serial.begin(9600);
}
 
void loop()
{
  analogWrite(ledPin, val);
  light = analogRead(lightSensorPin);
  motion = analogRead(motionSensorPin);
  if (light < 50 && !lightEnable){
    delay(1000);
    if (light < 50) lightEnable = true;
  }
  if (light > 50 && val == 0) lightEnable = false;
  if (motion > 150 && lightEnable){
    timerEnable = true;
    faderEnable = false;
  }
  if (timerEnable){
    timerCounter ++;    
    val = val + 1;
    if (val > 254) val = 254;
    if (timerCounter > timeOn * 50){
      if (motion < 150){
        //val = 0;
        timerCounter = 0;
        timerEnable = false;
        faderEnable = true;
      }
      else {
        timerCounter = 0;
      }
    }
  }
  if (faderEnable){
    val = val - 2;
    if (val < 0){
      faderEnable = false;  
      val = 0;
    }
  }  

 // Serial.println(light);
    delay(20);
}


, 3D , , .








, , , -, , , . , , 6 . Smart , . , — , .
, , : « Wi-Fi , , , , / », - .

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


All Articles