Raspberry Pi3 Chicken Coop Door

Good Morning did you get your LED lights figured out I just got a set going if interested pretty cheap, simple, with Pi3

Yes, I'm using DotStar fully addressable LED strip. Took me a bit to sort it out as the DotStar is 5v and the SPI on the Rpi is 3.3v but it turns out that 3.3v is enough to get the job done communicating.

I'd love to see what you have figured out.

JT
 
I'm using a 12 volt DC LED because I have 12 VDC to operate my door. You can link together up to 20 I used 4, 1 is fairly bright.
Link to LED
I also had to use something between Pi and 12V LED so I used
Onyehn 0-24V Top Mosfet Button IRF520 MOS Driver Module For Arduino MCU ARM Raspberry pi 6 Pack
Mosfet I used

The Mosfet wiring to Pi is really simple
20200818_040705.jpg


This is the code I'm using pretty simple and adjustable.

Code:
import time
import RPi.GPIO as GPIO

# PWM Pin
led_pin = 12

# Use "GPIO" pin numbering
GPIO.setmode(GPIO.BOARD)

# Set LED pin as output
GPIO.setup(led_pin, GPIO.OUT)

# Initialize PMW this is the on off duty cycle
pwm = GPIO.PWM(led_pin, 100) # this number controls the speed of the cycle
pwm.start(0)

# Set PWM duty cycle to 90%, wait, then to 70% down to 5% then off
# Time is in seconds 1 minute = 60 seconds
# 900 seconds = 15 minutes to test change all time.sleep(2) this will be 2 # # seconds light will come on 2 seconds and dim down each cycle
pwm.ChangeDutyCycle(90)
time.sleep(900)  # 900 seconds = 15 minutes  15x60=900

pwm.ChangeDutyCycle(70)
time.sleep(900)

pwm.ChangeDutyCycle(50)
time.sleep(600)  # 600 seconds = 10 minutes

pwm.ChangeDutyCycle(30)
time.sleep(300) # 300 seconds =  5 minutes

pwm.ChangeDutyCycle(20)
time.sleep(150)  # 150 seconds = 2 1/2 minutes

pwm.ChangeDutyCycle(10)
time.sleep(150)

# Stop, cleanup, and exit
pwm.stop()
GPIO.cleanup()

If you are trying this out change all the time.sleep to (2) this will do each step for 2 seconds so you can see how it works and not be all day. Then I just use my crontab to run the script.
 
I'm using a 12 volt DC LED because I have 12 VDC to operate my door. You can link together up to 20 I used 4, 1 is fairly bright.
Link to LED

Thanks for the code, I've never messed with pwm so the example is a big help.

Which color LED did you use?

I'm going to try this but I use PyQt for most projects and get astral data updated each new day so I can turn the lights on coordinated with dawn to sunrise and off coordinated with sunset to dusk.

JT
 

New posts New threads Active threads

Back
Top Bottom