If your next project requires some lighting elements, the Neopixel is a great option.

It solves many problems with the main one being that you won’t have to strip and solder a dozen LEDs and wires. 

Neopixels are capable of animations, varying their brightness as well as colour changing with only one wire needed to control them.

But, does a neopixel need pwm?

A Neopixel does require PWM to control brightness and change color, however, you will not have to connect it to the PWM pin of a microcontroller. The neopixel can be connected to any standard microcontroller input/output pin. The Integrated circuit onboard the neopixel does the job of providing PWM. 

Neopixel and PWM: A deeper look

The question of whether a neopixel requires PWM is a bit vague. 

I’m going to dissect the question into two parts;

  • Does a neopixel need PWM? and
  • Do you need to connect the neopixel to the PWM pin of a microcontroller?

Does a neopixel need PWM?

Let’s take a look at the first part of the dissected question.

Neopixels are individually addressable RGB LEDs that come in a variety of forms that include, flexible wire strands, rings, strips and more.

They are a brand developed by Adafruit Industries. 

But, controlling the brightness and colour of LEDs doesn’t just happen by magic.

So, does a neopixel need PWM?

Yes, a neopixel does require a process known as Pulse Width Modulation (PWM) which a technique used to vary power.

I will discuss how PWM is used to control brightness and colour of a neopixel in more detail further in the article.

Do you need to connect the neopixel to the PWM pin of a microcontroller?

So, we know that the neopixel needs PWM. 

But, the second part of the question is do you need to provide PWM to the neopixel by connecting it to the PWM pin of a microcontroller?

No, you do not need to provide PWM to the neopixel.

Then where does this PWM come from? 

The beauty of the neopixel is that one single RGB LED comes equipped with a controller (WS2811 and WS2812 which are produced by World Semi) that has the job of providing PWM to that particular LED module so the brightness and colour can be altered.

So, you will not have to provide PWM to the neopixel. This is all done onboard the neopixel itself.

How do you address each individual neopixel?

With the ability to control each LED  of the neopixel individually, you wouldn’t be blamed for thinking that you would need an output pin for each of those LEDs.

However, another great feature of the neopixel is it just has three wires. 

Yes, only three wires!

The three wires of the neopixel are Ground, +5V and Data (Data IN/OUT). 

As mentioned earlier, the neopixel has a controller built into the LED. 

This controller enables one-wire communication which means that you can use one wire and an output of a microcontroller to control several LEDs.

To reiterate, the data pin does not have to be connected to a PWM output pin. It can be connected to any standard digital input/output pins. 

How to drive neopixels without PWM

Connecting the neopixel isn’t a daunting experience and only requires a few bits and bobs.

However, you will need a microcontroller (like an Arduino) to interface it to.

Things you will need to connect a neopixel;

  • Neopixel
  • Micrcontroller 
  • +5V DC power supply
  • 470 ohms resistor (prevent spikes on the data line)
  • 1000uF capacitor (to prevent initial inrush current when using DC power supply or large battery)

Below is the schematic of the circuit for connecting a neopixel to a microcontroller.

Note, if you are new to programming and using microcontrollers, I would strongly recommend using an Arduino.

Adafruit have already created libraries with code designed specifically for the neopixel and an Arduino.

It has simplified functions you can use to control the neopixel.

Also, Arduinos have a great community as well as resources which can help you when you come across any problems. 

How PWM controls brightness of neopixel

We saw earlier that the neopixel needs PWM (which is taken care of by the controller) in order to vary the brightness of the LEDs.

Let’s take a closer look at a PWM and how it is used to vary the brightness of an LED.

Pulse width modulation is a technique used to vary the power delivered to certain electronic components which can include speakers, motors and LEDs.

With a motor, the speed is varied.

Whereas light sources, like LEDs, brightness is varied. 

It does this by switching the power to the components on and off very quickly.

The average power is determined by the ratio of ‘on’ vs ‘off’ which is also known as the Duty Cycle.

So, for example if the power is constantly on, the duty cycle is said to be 100%, so the power delivered to the neopixel is 100% of the supply voltage and will be at full brightness.

Now if the power is turned ‘on’ for 50% of the time, and turned ‘off’ for 50% of the time, the duty cycle will be 50% of the total supply voltage. 

Below are some duty cycle waveforms. 

How PWM controls color of neopixel  

One single neopixel LED module doesn’t just have one LED, but three.

The three colours of the LEDs are the primary colours Red, Green, and Blue. 

These colours are chosen as a wide variety of colours can be produced by just combining any of these three colours. 

PWM is once again used to vary the brightness of these three LEDs which blend the light produced by each LED in different combinations to give us a plethora of colours.