MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord

    Request for help: LED Control module for and 5050smd strip

    Requests
    led module smd5050 mosfet coding
    3
    5
    1921
    Loading More Posts
    • 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.
    • D
      disease last edited by

      I am looking for some help with a problem I’ve been trying to wrap my head around for about 4 month now. I have a 5m length of analogue LED strip (smd5050) that I want to attach surrounding my mirror providing lighting for the missus to be able to do her makeup etc. I have already prepped a circuit board using mosfets to control the strip as done in this tutorial https://dordnung.de/raspberrypi-ledstrip/. I’m however stuck on the software side, I haven’t done much JavaScript in some time and even then my knowledge was very basic. I’m looking to create a module with a) a button for on and off, b) a timer that can be set in config to auto turn off light if left on c) three vertical sliders to control the individual rub values of the strip. I know it’s pretty specific, I’m looking for some direction on how to achieve these things especially in regards to the sliders. Thanks in advance.

      1 Reply Last reply Reply Quote 0
      • cruunnerr
        cruunnerr last edited by

        Hey mate,

        here u can see my result: https://forum.magicmirror.builders/topic/6048/my-first-mirror-until-now/2

        i used this tutorial: https://dordnung.de/raspberrypi-ledstrip/

        its not a module for MM. But you can use Pigpio with an external script.
        Just use the PIR or a button to turn on and off the lights.

        in my case the PIR starts a script where it turns on the monitor and turn on the mosfets slowly.

        For the PIR i used this:

        #!/usr/bin/env python
        
        import sys
        import time
        import RPi.GPIO as io
        import subprocess
        import pigpio
        
        io.setmode(io.BCM)
        SHUTOFF_DELAY = 119 # seconds
        PIR_PIN = 25       # 22 on the board
        LED_PIN = 16
        
        def main():
            io.setup(PIR_PIN, io.IN)
            io.setup(LED_PIN, io.OUT)
            turned_off = False
            last_motion_time = time.time()
        
            while True:
                if io.input(PIR_PIN):
                    last_motion_time = time.time()
                    io.output(LED_PIN, io.LOW)
                    print ".",
                    sys.stdout.flush()
                    if turned_off:
                        turned_off = False
                        turn_on()
                else:
                    if not turned_off and time.time() > (last_motion_time +
                                                         SHUTOFF_DELAY):
                        turned_off = True
                        turn_off()
                    if not turned_off and time.time() > (last_motion_time + 1):
                        io.output(LED_PIN, io.HIGH)
                time.sleep(.1)
        
        def turn_on():
                subprocess.call("sh /home/pi/lights_on.sh", shell=True)
        
        def turn_off():
                subprocess.call("sh /home/pi/lights_off.sh", shell=True)
        
        if __name__ == '__main__':
            try:
                main()
            except KeyboardInterrupt:
                io.cleanup()
        

        And the script (lights_on and lights_off) which will be executed by detection looks like this:

        lights_on:

        sudo tvservice -p
        
        sleep 0.02
        
        pigs p 17 1
        pigs p 22 1
        pigs p 24 1
        
        sleep 0.06s
        
        pigs p 17 2
        pigs p 22 2
        pigs p 24 2
        
        sleep 0.06s
        
        pigs p 17 3
        pigs p 22 3
        pigs p 24 3
        
        sleep 0.06s
        
        pigs p 17 4
        pigs p 22 4
        pigs p 24 4
        
        sleep 0.06s
        
        pigs p 17 5
        pigs p 22 5
        pigs p 24 5
        
        sleep 0.06s
        
        pigs p 17 6
        pigs p 22 6
        pigs p 24 5
        
        sleep 0.06s
        
        pigs p 17 7
        pigs p 22 7
        pigs p 24 6
        
        sleep 0.06s
        
        pigs p 17 8
        pigs p 22 8
        pigs p 24 7
        
        sleep 0.06s
        
        pigs p 17 9
        pigs p 22 9
        pigs p 24 8
        
        sleep 0.06s
        
        pigs p 17 10
        pigs p 22 10
        pigs p 24 9
        
        sleep 0.06s
        
        pigs p 17 11
        pigs p 22 11
        pigs p 24 10
        
        sleep 0.06s
        
        pigs p 17 12
        pigs p 22 12
        pigs p 24 11
        

        lights_off:

        pigs p 17 12
        pigs p 22 12
        pigs p 24 11
        
        sleep 0.06s
        
        pigs p 17 11
        pigs p 22 11
        pigs p 24 10
        
        sleep 0.06s
        
        pigs p 17 10
        pigs p 22 10
        pigs p 24 9
        
        sleep 0.06s
        
        pigs p 17 9
        pigs p 22 9
        pigs p 24 8
        
        sleep 0.06s
        
        pigs p 17 8
        pigs p 22 8
        pigs p 24 7
        
        sleep 0.06s
        
        pigs p 17 7
        pigs p 22 7
        pigs p 24 6
        
        sleep 0.06s
        
        pigs p 17 6
        pigs p 22 6
        pigs p 24 5
        
        sleep 0.06s
        
        pigs p 17 5
        pigs p 22 5
        pigs p 24 5
        
        sleep 0.06s
        
        pigs p 17 4
        pigs p 22 4
        pigs p 24 4
        
        sleep 0.06s
        
        pigs p 17 4
        pigs p 22 4
        pigs p 24 4
        
        sleep 0.06s
        
        sudo tvservice -o
        pigs p 17 3
        pigs p 22 3
        pigs p 24 3
        
        sleep 0.06s
        
        pigs p 17 2
        pigs p 22 2
        pigs p 24 2
        
        sleep 0.06s
        
        pigs p 17 1
        pigs p 22 1
        pigs p 24 1
        
        sleep 0.06s
        
        pigs p 17 0
        pigs p 22 0
        pigs p 24 0
        
        
        metalldetector 1 Reply Last reply Reply Quote 3
        • D
          disease last edited by

          That kind of does what I want in a round about way, I do want the sliders though as I do want to be able to control the colour, I do there is a python script which does just this from a book entitled “Programming the raspberry pi” the author has a github which has open access to the script. Essentially the script opens up a Tkinter window with sliders for each colour. Would it be possible to incorporate the sliders into a module, I’m a little fuzzy on how the modules work if they are entirely JavaScript or if HTML is possible?

          1 Reply Last reply Reply Quote 0
          • D
            disease last edited by

            So I’ve found another possibility to do everything I need, I found a website showing me how to setup a secondary web server to control the led strip, I’ve modified it to my specifications but I’m stuck on how to implement it into my mirror. I am able to view the webpage via my pi’s ip and port however the webpage won’t seem to work in an iframe module as I had hoped.

            1 Reply Last reply Reply Quote 0
            • metalldetector
              metalldetector @cruunnerr last edited by

              habe alles nach anleitung verkabelt… die pins geändert vom pir …
              habe pigpio installiert und rebootet
              der pir reagiert auch aber bildschirm bleibt grau… dh ohne bild… monitor ist aber an.
              led streifen leuchtet aber nicht…

              was kann das sein
              thx

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              Enjoying MagicMirror? Please consider a donation!
              MagicMirror created by Michael Teeuw.
              Forum managed by Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
              This forum is using NodeBB as its core | Contributors
              Contact | Privacy Policy