Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. My Project
  3. Backlit Dimmable LED Mirror with Motion Sensor

Backlit Dimmable LED Mirror with Motion Sensor

Scheduled Pinned Locked Moved My Project
43 Posts 12 Posters 30.9k Views 14 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H henno

    @petewill Just wanted to let you know that I've built two of these for my daughters but instead of putting them behind a mirror I put it under their bed. Works really good, thanks for sharing!

    hekH Offline
    hekH Offline
    hek
    Admin
    wrote on last edited by
    #20

    @henno said:

    I've built two of these for my daughters but instead of putting them behind a mirror I put it under their bed.

    Scares away all the monsters? :trollface:

    1 Reply Last reply
    0
    • H henno

      @petewill Just wanted to let you know that I've built two of these for my daughters but instead of putting them behind a mirror I put it under their bed. Works really good, thanks for sharing!

      DrJeffD Offline
      DrJeffD Offline
      DrJeff
      wrote on last edited by
      #21

      @henno That is too funny I was at a hotel and they had LEDs under the cabinets with motion sensors to light the floor. So when I came home I knew I saw some guy doing something similar to a mirror that I'm gonna steal for under my bed to walk at night without bumping my toes! Thanks Pete!

      1 Reply Last reply
      0
      • C Offline
        C Offline
        csa02221862
        wrote on last edited by
        #22

        For those of us without a central 12v system do you know what the current draw is?

        What is your system setup? Thinking of doing the same.

        petewillP 1 Reply Last reply
        0
        • C csa02221862

          For those of us without a central 12v system do you know what the current draw is?

          What is your system setup? Thinking of doing the same.

          petewillP Offline
          petewillP Offline
          petewill
          Admin
          wrote on last edited by
          #23

          @csa02221862 Sorry for the delayed reply. Unfortunately I don't remember what the power draw is. I believe it is around 1.5A but can't say for sure.

          My "How To" home automation video channel: https://www.youtube.com/channel/UCq_Evyh5PQALx4m4CQuxqkA

          1 Reply Last reply
          0
          • C Offline
            C Offline
            csa02221862
            wrote on last edited by
            #24

            Thanks. I'm hopeing to do a "ehole house" 12v system also. What is your power source. I've been looking at

            http://www.banggood.com/AC110V-220V-To-DC12V-12_5A-150W-Voltage-Transformer-Switch-Power-Supply-For-LED-Strip-p-984967.html?currency=USD&createTmp=1&utm_source=google&utm_medium=shopping&utm_content=saul&utm_campaign=led-gadget-US&gclid=Cj0KEQjw44exBRCu8vfS_bPEtNoBEiQACrt002cdBU-mBxB0Z5PGsGCkTgwp37OcWYL28zNGmJNjTu8aAitZ8P8HAQ

            Thoughts?

            petewillP 1 Reply Last reply
            0
            • C csa02221862

              Thanks. I'm hopeing to do a "ehole house" 12v system also. What is your power source. I've been looking at

              http://www.banggood.com/AC110V-220V-To-DC12V-12_5A-150W-Voltage-Transformer-Switch-Power-Supply-For-LED-Strip-p-984967.html?currency=USD&createTmp=1&utm_source=google&utm_medium=shopping&utm_content=saul&utm_campaign=led-gadget-US&gclid=Cj0KEQjw44exBRCu8vfS_bPEtNoBEiQACrt002cdBU-mBxB0Z5PGsGCkTgwp37OcWYL28zNGmJNjTu8aAitZ8P8HAQ

              Thoughts?

              petewillP Offline
              petewillP Offline
              petewill
              Admin
              wrote on last edited by
              #25

              @csa02221862 Depending on what you want to run it may be a little under powered. For the last year and a half I have been using a hacked 300 watt PC power supply. I originally just set it up as a temporary measure but it has been working great. I have even made some stupid wiring mistakes and shorted it out a few times. Each time I just fix the mistake and it powers right back on. I need to make a video of how I set everything up but I have had so little time lately...

              My "How To" home automation video channel: https://www.youtube.com/channel/UCq_Evyh5PQALx4m4CQuxqkA

              1 Reply Last reply
              0
              • C Offline
                C Offline
                csa02221862
                wrote on last edited by
                #26

                Thanks for the info. I may get this for use in the "lab" and see what you are doing with the computer power supply when you do the video. I believe many of us would like to have a 12v/5v power distribution system in the house.

                Your videos are OUTSTANDING!

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  csa02221862
                  wrote on last edited by
                  #27

                  Looking forward to the "whole house power" video.

                  I'm building this for two mirrors as well as kitchen under counter and bookcase down lighting.

                  Your Vera videos have been MOST helpful. You do great "practical" work.

                  THANKS AGAIN!

                  petewillP 1 Reply Last reply
                  0
                  • C csa02221862

                    Looking forward to the "whole house power" video.

                    I'm building this for two mirrors as well as kitchen under counter and bookcase down lighting.

                    Your Vera videos have been MOST helpful. You do great "practical" work.

                    THANKS AGAIN!

                    petewillP Offline
                    petewillP Offline
                    petewill
                    Admin
                    wrote on last edited by
                    #28

                    @csa02221862 Great! I have these all around my house in various places and I love them. All credit goes to @blacey.

                    I do need to work on the power video. There are so many things I want to work on I have been focusing on making videos as I work on new sensors. It's so hard to find time these days...

                    My "How To" home automation video channel: https://www.youtube.com/channel/UCq_Evyh5PQALx4m4CQuxqkA

                    1 Reply Last reply
                    0
                    • Dave DanD Offline
                      Dave DanD Offline
                      Dave Dan
                      wrote on last edited by
                      #29

                      @petewill ,

                      I have a question on this project.

                      I'm replicating it for a wider mirror and I was thinking about having two separate dimming zones ( left and right ). based on the sketch and the design: Do you think One arduino can control both sides or do I need 2 different arduinos (+ electronics) and one won't be enough.

                      Happy to details more if needed.

                      thanks in advance!

                      petewillP 1 Reply Last reply
                      0
                      • Dave DanD Dave Dan

                        @petewill ,

                        I have a question on this project.

                        I'm replicating it for a wider mirror and I was thinking about having two separate dimming zones ( left and right ). based on the sketch and the design: Do you think One arduino can control both sides or do I need 2 different arduinos (+ electronics) and one won't be enough.

                        Happy to details more if needed.

                        thanks in advance!

                        petewillP Offline
                        petewillP Offline
                        petewill
                        Admin
                        wrote on last edited by
                        #30

                        @Dave-Dan said:

                        Do you think One arduino can control both sides or do I need 2 different arduinos (+ electronics) and one won't be enough.

                        Definitely. I have one pro mini controlling 3 different dimmers. You just need to make sure you use PWM pins for the outputs.

                        My "How To" home automation video channel: https://www.youtube.com/channel/UCq_Evyh5PQALx4m4CQuxqkA

                        1 Reply Last reply
                        0
                        • Dave DanD Offline
                          Dave DanD Offline
                          Dave Dan
                          wrote on last edited by
                          #31

                          Cool, thanks for the quick reply.

                          I'm going to test this this weekend and see if I can make it work :)

                          1 Reply Last reply
                          0
                          • C Offline
                            C Offline
                            csa02221862
                            wrote on last edited by csa02221862
                            #32

                            Do you have the Fitzing and code for the 3 zone? I have several places to use this. Any "max wattage" info, per channel and total?

                            Thanks,
                            Richard

                            petewillP 1 Reply Last reply
                            0
                            • C csa02221862

                              Do you have the Fitzing and code for the 3 zone? I have several places to use this. Any "max wattage" info, per channel and total?

                              Thanks,
                              Richard

                              petewillP Offline
                              petewillP Offline
                              petewill
                              Admin
                              wrote on last edited by
                              #33

                              @csa02221862

                              Sorry it has been too long since I made this video and I don't remember the reference. If you're talking about my Arduino that dims three separate lights it's basically just the same wiring except you use 3 different PWM pins to the 3 different MOSFETs. The max wattage is determined by the MOSFET you use.

                              If that's not what you're referring to, let me know.

                              My "How To" home automation video channel: https://www.youtube.com/channel/UCq_Evyh5PQALx4m4CQuxqkA

                              C 1 Reply Last reply
                              0
                              • petewillP petewill

                                @csa02221862

                                Sorry it has been too long since I made this video and I don't remember the reference. If you're talking about my Arduino that dims three separate lights it's basically just the same wiring except you use 3 different PWM pins to the 3 different MOSFETs. The max wattage is determined by the MOSFET you use.

                                If that's not what you're referring to, let me know.

                                C Offline
                                C Offline
                                csa02221862
                                wrote on last edited by
                                #34

                                @petewill Yes that's what I'm talking about. Just wondering how the code was modified to discretely control the 3 zones.

                                BulldogLowellB petewillP 2 Replies Last reply
                                0
                                • C csa02221862

                                  @petewill Yes that's what I'm talking about. Just wondering how the code was modified to discretely control the 3 zones.

                                  BulldogLowellB Offline
                                  BulldogLowellB Offline
                                  BulldogLowell
                                  Contest Winner
                                  wrote on last edited by
                                  #35

                                  @csa02221862 said:

                                  @petewill Yes that's what I'm talking about. Just wondering how the code was modified to discretely control the 3 zones.

                                  you want with or without the buttons?

                                  If with, how would the buttons work?

                                  1 Reply Last reply
                                  0
                                  • C csa02221862

                                    @petewill Yes that's what I'm talking about. Just wondering how the code was modified to discretely control the 3 zones.

                                    petewillP Offline
                                    petewillP Offline
                                    petewill
                                    Admin
                                    wrote on last edited by
                                    #36

                                    @csa02221862 Sorry for the delayed reply. Busy day yesterday. Here is my code that I'm running in my 1.4.1/1.5 environment.

                                    /***
                                     * This program is free software; you can redistribute it and/or
                                     * modify it under the terms of the GNU General Public License
                                     * version 2 as published by the Free Software Foundation.
                                     * 
                                     * DESCRIPTION
                                     * This sketch provides a Dimmable LED Light using PWM and based Henrik Ekblad 
                                     * <henrik.ekblad@gmail.com> Vera Arduino Sensor project.  
                                     * Developed by Bruce Lacey, inspired by Hek's MySensor's example sketches.
                                     * 
                                     * The circuit uses a MOSFET for Pulse-Wave-Modulation to dim the attached LED or LED strip.  
                                     * The MOSFET Gate pin is connected to Arduino pin 3 (LED_PIN), the MOSFET Drain pin is connected
                                     * to the LED negative terminal and the MOSFET Source pin is connected to ground.  
                                     *
                                     * This sketch is extensible to support more than one MOSFET/PWM dimmer per circuit.
                                     *
                                     * REVISION HISTORY
                                     * Version 1.0 - February 15, 2014 - Bruce Lacey
                                     * Version 1.1 - August 13, 2014 - Converted to 1.4 (hek)
                                     * Version 1.2 - January 22, 2015 - Created a seperate control for the basement LEDs 
                                     * Version 1.3 - March 7, 2015 - Added coat closet LED
                                     *
                                     ***/
                                    #define SN "Basement LEDs"
                                    #define SV "1.3"
                                    
                                    #include <MySensor.h> 
                                    #include <SPI.h>
                                    
                                    #define NODE_ID AUTO //Change to a number to manually assign a node ID
                                    
                                    #define MASTER_WINDOW_LED_CHILD 0
                                    #define COAT_CLOSET_LED_CHILD 1
                                    #define UPSTAIRS_RAIL_LED_CHILD 30
                                    #define BASEMENT_DESK_LED_CHILD 40
                                    
                                    #define MASTER_WINDOW_LED_PIN 3      // Arduino pin attached to MOSFET Gate pin
                                    #define UPSTAIRS_RAIL_LED_PIN 5
                                    #define BASEMENT_DESK_LED_PIN 6
                                    #define COAT_CLOSET_LED_PIN 9
                                    
                                    #define FADE_DELAY 10  // Delay in ms for each percentage fade up/down (10ms = 1s full-range dim)
                                    
                                    //MySensor gw;
                                    MySensor gw(4, 10);  //Change CE PIN to free up another PWM pin
                                    
                                    static int currentLevelUpstairsRail = 0;
                                    static int currentLevelBasementDesk = 0;
                                    static int currentLevelMasterWinLight = 0;
                                    static int currentLevelCoatCloset = 0;
                                    
                                    
                                    /***
                                     * Dimmable LED initialization method
                                     */
                                    void setup()  
                                    { 
                                      Serial.println( SN ); 
                                      gw.begin( incomingMessage,  NODE_ID);
                                      
                                      // Register the LED Dimmable Light with the gateway
                                      gw.present(UPSTAIRS_RAIL_LED_CHILD, S_DIMMER );
                                      gw.present(BASEMENT_DESK_LED_CHILD, S_DIMMER ); 
                                      gw.present(MASTER_WINDOW_LED_CHILD, S_DIMMER );
                                      gw.present(COAT_CLOSET_LED_CHILD, S_DIMMER );
                                      
                                      gw.sendSketchInfo(SN, SV);
                                    }
                                    
                                    /***
                                     *  Dimmable LED main processing loop 
                                     */
                                    void loop() 
                                    {
                                      gw.process();
                                    }
                                    
                                    
                                    
                                    void incomingMessage(const MyMessage &message) {
                                      if (message.type == V_LIGHT || message.type == V_DIMMER) {
                                        
                                        //  Retrieve the power or dim level from the incoming request message
                                        int requestedLevel = atoi( message.data );
                                        
                                        // Adjust incoming level if this is a V_LIGHT variable update [0 == off, 1 == on]
                                        requestedLevel *= ( message.type == V_LIGHT ? 100 : 1 );
                                        
                                        // Clip incoming level to valid range of 0 to 100
                                        requestedLevel = requestedLevel > 100 ? 100 : requestedLevel;
                                        requestedLevel = requestedLevel < 0   ? 0   : requestedLevel;
                                        
                                    //    Serial.print( "Changing level to " );
                                    //    Serial.println( requestedLevel );
                                    
                                    
                                        //fadeToLevel( requestedLevel );//old code
                                        fadeToLevel( message.sensor, requestedLevel );
                                        }
                                    }
                                    
                                    
                                    
                                    void fadeToLevel(int ledChild, int toLevel ) {
                                    //    Serial.print( "In the FadeToLevel method.  ChildID: " );
                                    //    Serial.println( ledChild );
                                    
                                      int currentLevel;
                                      int ledPin;
                                      
                                      if(ledChild == UPSTAIRS_RAIL_LED_CHILD){
                                        currentLevel = currentLevelUpstairsRail;
                                        ledPin = UPSTAIRS_RAIL_LED_PIN; 
                                      }
                                      else if(ledChild == MASTER_WINDOW_LED_CHILD){
                                        currentLevel = currentLevelMasterWinLight;
                                        ledPin = MASTER_WINDOW_LED_PIN;
                                      }
                                      else if(ledChild == COAT_CLOSET_LED_CHILD){
                                        currentLevel = currentLevelCoatCloset;
                                        ledPin = COAT_CLOSET_LED_PIN;
                                      }
                                      else{
                                        currentLevel = currentLevelBasementDesk;
                                        ledPin = BASEMENT_DESK_LED_PIN;
                                      }
                                      
                                      int delta = ( toLevel - currentLevel ) < 0 ? -1 : 1;
                                      
                                      while ( currentLevel != toLevel ) {
                                        currentLevel += delta;
                                        analogWrite(ledPin, (int)(currentLevel / 100. * 255) );
                                        delay( FADE_DELAY );
                                    //    Serial.println( ledPin );
                                      }
                                      
                                      if(ledChild == UPSTAIRS_RAIL_LED_CHILD){
                                        currentLevelUpstairsRail = toLevel;
                                      }
                                      else if(ledChild == MASTER_WINDOW_LED_CHILD){
                                        currentLevelMasterWinLight = toLevel;
                                      }
                                      else if(ledChild == COAT_CLOSET_LED_CHILD){
                                        currentLevelCoatCloset = toLevel;
                                      }
                                      else{
                                        currentLevelBasementDesk = toLevel;
                                      }
                                        //gw.sendVariable( ledChild, V_LIGHT,  currentLevel > 0 ? 1 : 0 ); 
                                        //gw.sendVariable( ledChild, V_DIMMER, currentLevel );
                                        MyMessage dimmerMsg(ledChild,  V_DIMMER);
                                        gw.send(dimmerMsg.set(currentLevel));
                                        
                                      
                                    }```

                                    My "How To" home automation video channel: https://www.youtube.com/channel/UCq_Evyh5PQALx4m4CQuxqkA

                                    1 Reply Last reply
                                    1
                                    • C Offline
                                      C Offline
                                      csa02221862
                                      wrote on last edited by csa02221862
                                      #37

                                      Pete, thanks.

                                      This will work for most situations I need. Is there an option to add the buttons and motion to one or more of the led's?

                                      Hate to bother you again.

                                      Richard

                                      petewillP 1 Reply Last reply
                                      0
                                      • C csa02221862

                                        Pete, thanks.

                                        This will work for most situations I need. Is there an option to add the buttons and motion to one or more of the led's?

                                        Hate to bother you again.

                                        Richard

                                        petewillP Offline
                                        petewillP Offline
                                        petewill
                                        Admin
                                        wrote on last edited by
                                        #38

                                        @csa02221862 It should be possible but I never added it. This is in my basement controlling various lights throughout my house so I don't need buttons very often (when I do I just use my phone). The motion sensors are run through a different node and all the logic happens through my controller.

                                        My "How To" home automation video channel: https://www.youtube.com/channel/UCq_Evyh5PQALx4m4CQuxqkA

                                        1 Reply Last reply
                                        0
                                        • loralgL Offline
                                          loralgL Offline
                                          loralg
                                          wrote on last edited by
                                          #39

                                          @petewill Thanks for an awesome write up, I just recently ran across it! I am trying to get it working and downloaded the 1.4 library and tried uploading the sketch to my pro mini and got the following error:

                                          Sketch uses 18,642 bytes (130%) of program storage space. Maximum is 14,336 bytes.
                                          Global variables use 633 bytes (61%) of dynamic memory, leaving 391 bytes for local variables. Maximum is 1,024 bytes.
                                          processing.app.debug.RunnerException: Sketch too big; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it.
                                          at cc.arduino.Compiler.size(Compiler.java:315)
                                          at cc.arduino.Compiler.build(Compiler.java:156)
                                          at processing.app.Sketch.build(Sketch.java:1111)
                                          at processing.app.Sketch.exportApplet(Sketch.java:1146)
                                          at processing.app.Sketch.exportApplet(Sketch.java:1132)
                                          at processing.app.Editor$DefaultExportHandler.run(Editor.java:2409)
                                          at java.lang.Thread.run(Thread.java:745)
                                          Sketch too big; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it.

                                          Any suggestions on what I might be doing wrong? I am pretty new so I might be overlooking something really simple..

                                          petewillP 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          10

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular