0

I am using my raspberry pi 3 to run some services. When someone powers on the Raspberry I want to use RGB LEDs to indicate the status instead of using a LCD screen to output messages. The LEDs I plan on using are digital meaning I can turn the first LED green the second red and so on unlike a analog LED strip where you turn on all the lights at the same time with the same color. This video illustrates a digital led strip connected to a raspberry pi 3 https://youtu.be/zlpjlY_MfeA

Anyways the LED strip that I bought and plan on using is this one: enter image description here


Before continuating with the question:

Is the input/signal from the first diagram (LED strip that I got) a PWM signal? I assume it is otherwise I have to rephrase the title of this question. This confuses me because the LED strip is digital and PWM is analog? Moreover there are other digital LED strips that have 4 pins like this one:enter image description here Does that digital LED strip uses PWM as well? Sorry I am new to the embedded world I am probably wrong on this.


Back to the question:

There are lots of tutorials on the internet on how to turn on digital LED strips such as this amazing one: https://tutorials-raspberrypi.com/connect-control-raspberry-pi-ws2812-rgb-led-strips/ . But none of them show how to do this at boot time or maybe I have not searched enough.

So my question is how can I do this at boot time? All this tutorials show you how to do it once your raspberry pi boots (after /etc/rc.local). The reason why I want to use the LED strip is to show the status of the raspberry pi. When it is booting I will like to show the LEDs flashing with yellow for example. The board takes 14 seconds to boot and the LEDs are off until the pi boots. I do not want to wait 14 seconds to show the status. I just want to send a constant PWM signal throughout a GPIO pin on my raspberry and once the computer boots I could change that signal

  • PWM is a digital signal. it is a digital representation of an analog signal. ... imagine a bucket that is 1/2 full of water. ... the bucket has a hole in the bottom that allows some of the water to run out. ... you have a water hose that you can only turn on or off (nothing in between) .... if you turn the water on, it will quickly overfill the bucket ... your job is to keep the bucket filled 1/2 way. ... you would briefly turn the water on, then turn it off and wait for the level to drop a bit ... then you would repeat ... that is using PWM to produce a trickle of water from the hose – jsotola Mar 6 '18 at 6:41
3

PWM (Pulse Width Modulation) applies to digital as well as analogue signals.

Individually addressable LED strips, such as you want to use, are not controlled by PWM signals. They are controlled by a bit stream to set the RGB values of individual LEDs.

You will not be able to send any meaningful data to such a LED strip until the Pi has booted, i.e. you will have a 14 second delay or so.

  • Thanks so much for the help. What is a bit stream? – Tono Nam Mar 5 '18 at 21:38
  • It just means the series of 1s and 0s you send to a device. For a LED strip it might be 32 0 bits to signal start, then 24 bits of RGB data for LED 1, 8 bits of brightness data for LED1, then the same for each subsequent LED, until the last, then repeat ad infinitum. – joan Mar 5 '18 at 21:49
  • "You will not be able to send any meaningful data to such a LED strip until the Pi has booted". I think there are work-arounds, communication can be started much earlier in the boot process if desired, however it would at a minimum require a custom initramfs image and/or a custom kernel module. In other words, not trivial. – crasic Mar 5 '18 at 22:48
-2

like joan said, PWM is technically digital. it works by flashing voltage on and off very very fast to simulate analog.

you can not control a digital led strip before the raspberry pi boots, although you can just after it boots by adding your script to the end of /etc/profile or /etc/rc.local . you could, though, by a seperate (analog, maybe even flashing!) rgb led or strip and wire one of its colors to the 5v and GND pins or the rpi, so it turned on right away, then once the rpi is fully on you could activate one of the other colors to turn, say, blue into purple.

  • 2
    This is POOR advice. /etc/profile is a system-wide .profile file for the Bourne shell and MUST not be used to run user code. /etc/rc.local is obsolete, and while it still works, to some extent, on a systemd OS is a poor choice. – Milliways Mar 6 '18 at 3:08
  • sorry @Milliways I am new to stack exchange and I'll delete this. I have always used /etc/profile and did not know you shouldn't. thanks for the advice. – scitronboy Mar 6 '18 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.