Are you confused about how to connect and control White LED Strips via Raspberry Pi? In this passage, we will introduce every single detail of the whole process, including tools you need to prepare, wire connection, code upload and the final effect.
1. Preparation
Raspberry Pi Board
Raspberry Pi, a small and not expensive single-board computer that is developed by the Raspberry Pi Foundation (UK), was originally intended to promote computer science. Due to its low cost and adaptability, it is now commonly utilized as a complete computer and deployed in different areas such as media center, VPN servers, network monitors or ad-blockers. Key models of the Raspberry Pi include the high-performance Raspberry Pi 4 and the extremely small Raspberry Pi Zero. For more information, please follow this passage.
Power Supply
DC5V LED Driver
- Output Voltage: DC5V
- Power: 400W
Function:
- To power the LED strip and Raspberry Pi after the voltage transition via converter.
We also supply waterproof power supply for outdoor use. Please check our page: Waterproof Power Supply.
4-way level converter
Designed for high-voltage applications such as HVDC transmission and large motor drives, the 4-level converter is a power electronic circuit. Unlike basic converters which produce only high or low output voltage, the converter generates four discrete voltage levels at its output terminal. Through special arrangement of the semiconductor switches with DC sources and capacitors, the converter creates a stepped and staircase-shaped waveform, which substantially lowers the output voltage harmonic distortion, decreases component stress and enhances the efficiency. All of these help to provide superior power quality, particularly at high power ratings.
5V White LED Strip
Specifications:
- Voltage: 5V
- LED Qty: 60LEDs/m
- Feature: White LED strips mainly use SDM 2835 LED. The power of this regular white led strip is adjustable. Although we suggest the standard power, other power is also available, such as 8W/m, 10W/m, 14W/m, 15W/m, 16W/m, 18W/m etc. Please click SMD LED Strip to find more information about regular white led strip.
2. Raspberry Pi 4B Control Board Monochrome White LED Strip Wiring Diagram
Reminder:
1. An external power supply will be nccessary to power the light strip.
2.The DC3.3/5V interface is the voltage output port of the controlboard, which cannot be connected to the power supply. The controlboard is powered by a dedicated PD power supply(5.1V-5A)
3. This wiring diagram is a common anode, please note that theprogramis a common anode program;
4. The GPlO of Raspberry Pi 4B is a 3.3V logic level. lt is recommendedto add a 220 ohm-1K ohm resistor or a level converter between GPiOand the light strip (to prevent overcurrent damage).
3. Raspberry Pi Sngle White LED Connection Diagram
As shown in this picture, several wires on the Raspberry Pi should be always fixed and we only need to adjust the wire connection on the data PIN and GND PIN.
4. Code Upload
mport RPi.GPIO as GPIO
import time
# GPIO setup
LED_PIN = 18 # PWM output_PIN(GPIO 18)
GPIO.setmode(GPIO.BCM) # use BCM number
GPIO.setup(LED_PIN, GPIO.OUT)
# create PWM subject(frequency 1000Hz)
pwm = GPIO.PWM(LED_PIN, 1000)
pwm.start(0) # original_duty_cycle 0%(close)
try:
while True:
# brightness from 0% to 100% recycle
for duty_cycle in range(0, 101, 5): # 0%, 5%, 10%, ..., 100%
pwm.ChangeDutyCycle(duty_cycle)
time.sleep(0.1) # delay 0.1second for every step
# brightness from 100% to 0% recycle
for duty_cycle in range(100, -1, -5): # 100%, 95%, 90%, ..., 0%
pwm.ChangeDutyCycle(duty_cycle)
time.sleep(0.1) # delay 0.1second for every step
except KeyboardInterrupt:
print("close the setup")
pwm.stop() # stop PWM
GPIO.cleanup() # cleanup GPIO
5. Video of Final Effect
Please check the following video to have a closer look at the wore connection of all the items.
Regular white led strip could be dimmable and the brightness is adjustable by using the Raspberry Pi. Hope this passage will help with your projects.
If you are interested in how to control White LED Strip via another small controller board ESP32, please check this blog: