I want to control an LED Strip via the gpio PIns of my Raspberry pi 2. I found some ways for example using Python or WiringPi. But I need to use "non absolute values" like "put Pin 0 to 0.2 and Pin 2 to 0.9". As far as I know pi-blaster was used for this but sadly it isn't compatible to the new RPi2... Any ideas how I can realize this?


EDIT: So what I have: I have an Raspberry Pi 2 Model B and an RGB LED Strip with 4 wires (dc, red, green, blue) I wanted to use this tutorial to connect the strip to my RPi. I got everything connected correctly, everything is shining when it's meant to be, but now i need a software like pi-blaster which let mit use PWM (as some here mentioned). sadly i'm really new to things like that,I have my experience with linux and so on but wiring things together wasn't my business until now ;)

EDIT 2: I used GPIO 0, 2 and 3 so Pin 11, 13 and 15 http://pi4j.com/images/j8header-2b.png

  • Hello and welcome! I do not understand what you want to do - to be honest.
    – Ghanima
    Feb 18, 2015 at 20:31
  • most solutions only allow to set the Pins to ether 1 or 0 but some (for example pi-blaster) allow float values like 0.2 so the pin runs with a 20%
    – globus243
    Feb 18, 2015 at 21:12
  • While this starts to sound like "PWM" (see joans answer) the gpio pin is not outputting analogue values but switching between 0 and 1 "very fast". With a low-pass filter (or an integrator) - essentially a simple RC circuit - this signal can be turned into an analogue value, if that is what your LED strip needs. God answers could probably profit from a more detailed description of your task (e.g. what kind of LED strip).
    – Ghanima
    Feb 18, 2015 at 21:21

1 Answer 1


All the Pi's gpios are digital, you can not write analogue values to the Pi's gpios.

What you can do is use PWM to achieve the same effect.

There are several types of PWM supported on the Pi 2.

  1. two hardware PWM channels (in effect two gpios).
  2. software timed PWM on any gpio.
  3. hardware (DMA) timed PWM on any gpio.

All 3 methods are probably okay for hobby motor control.

For LEDs and servo pulses you really need to be using methods 1 or 3.

pi-blaster, servoblaster, my pigpio use method 3.

pigpio now works on the Pi 2.


Using the pigpio daemon there are two methods of control from the command line.

Note, by default, PWM values range from 0 (off) to 255 (fully on).

The example is for gpio 4 (pigpio only allows Broadcom gpio numbering).

sudo pigpiod # start the daemon

  1. pipe interface
echo "p 4 0"   >/dev/pigpio #   0%
echo "p 4 32"  >/dev/pigpio #  13%
echo "p 4 64"  >/dev/pigpio #  25%
echo "p 4 128" >/dev/pigpio #  50%
echo "p 4 255" >/dev/pigpio # 100%
  1. socket interface
pigs p 4 0   #   0%
pigs p 4 32  #  13%
pigs p 4 64  #  25%
pigs p 4 128 #  50%
pigs p 4 255 # 100%
  • Thank you for the quick answer. I downloaded and compiled as explaned in the documentation. Can you give a quick code example to set pin xy to 20% power? so to speak 'echo "xy=0,2" > /dev/pi-blaster' as I would do that with pi-blaster
    – globus243
    Feb 18, 2015 at 21:15
  • @globus243 Added a couple of examples to post.
    – joan
    Feb 18, 2015 at 21:29
  • mhh doesn't seem to work for me.. i checked with WiringPi, which worked, so the wiring is ok. do I need to initialize the used Pins somewhere? deamon is running I have root access something else to consider? I added a comment to my post, to show which Pins I used are they maybe "not compatible" or something? I tried all the Pins I used in the following manner echo "p 11 255" > /dev/pigpio echo "p 0 255 " > /dev/pigpio # just to be sure
    – globus243
    Feb 18, 2015 at 21:47
  • Ok I think I got it, I used the wrong scheme I need to use 17 27 and 22 en.wikipedia.org/wiki/Raspberry_Pi
    – globus243
    Feb 18, 2015 at 21:55
  • Yes, pigpio ALWAYS uses the Broadcom gpio number.
    – joan
    Feb 18, 2015 at 21:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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