Recalbox Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • recalbox.com
    • Gitlab repository
    • Documentation
    • Discord

    Control LED Strip With Relay And Startup Script

    Recalbox General
    control led strip relay startup
    2
    2
    1012
    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.
    • Kevin Mathis
      Kevin Mathis last edited by

      Hello there, my name is Kevin. Long time reader of the forums first time poster. Ive been building some cabinets and bartops for friends and family and wanted to take my builds to the next level by adding some lights. I wanted these lights to turn on and off upon boot and shutdown of the pi to keep things simple and organized without the need of doing anything else other than just powering on the pi.

      Ive gotten this to work on my own, but what id like to change is when the lights turn on. right now the lights turn on right when the ES screen pops up after the recalbox splash. What id like is for the LED to come on right when the pi gets power. before the actual recalbox splash screen. Ive included a video of what I mean. https://www.youtube.com/watch?v=B7rZnrQ61iY&frags=pl%2Cwn

      what I have so far is a Led strip connected to a 5v relay connected to the pi via gpio and a script that runs at startup from /recalbox/share/system/ called custom.sh

      heres the script im using, feel free to add any changes I should be making.

      #!/usr/bin/python
      # GPIO lib import
      import RPi.GPIO as GPIO
      import time
      
      channel = 18
      
      # GPIO setup
      GPIO.setmode(GPIO.BCM)
      GPIO.setup(channel, GPIO.OUT)
      

      I also have this script posted in /etc/init.d with no luck. but maybe im also not using the correct script.

      1 Reply Last reply Reply Quote 0
      • Dragu
        Dragu Banned last edited by Dragu

        @Kevin-Mathis

        As I posted otherwhere, you need no script for this. As USB are powered up by PI when system starts (all systems) and powered down at shutdown, with the PI always under power. So you just need to connect the relay at an USB power line, by cable or breakout adapter, as you want.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post

        Want to support us ?

        80
        Online

        98.6k
        Users

        28.1k
        Topics

        187.0k
        Posts

        Copyright © 2021 recalbox.com