Over a million developers have joined DZone.

Adafruit NeoPixels w/ the Freescale FRDM-K64F Board – Pt. 1

DZone's Guide to

Adafruit NeoPixels w/ the Freescale FRDM-K64F Board – Pt. 1

This project demonstrates controlling a NeoPixels board with the Freescale FRDM-K64F IoT board. In part one, learn about the hardware used.

· IoT Zone
Free Resource

This is Part 1 of a Mini Series. Manya has challenged herself to use the Adafruit NeoPixels (WS2812B RBG LEDs) with the Freescale FRDM-K64F board and the Kinetis SDK (see “Let’s play with Freescale FRDM-K64F“). I did a while back that with the FRDM-KL25Z board (see “NeoShield: WS2812 RGB LED Shield with DMA and nRF24L01+“). I used Processor Expert in my project (without the Kinetis SDK), and with this setup it is very easy. However, Manya wanted to do this with the Kinetis SDK and without Processor Expert. No surprise to me, she has found out that this setup with the Kinetis SDK and without the usage of Processor Expert is much more challenging (see “Not done yet!!“). I promised to Manya to give her a helping hand, so here we go! :-)

Adafruit 8x8 NeoPixel Shield with Freescale FRDM-K64F Board

Adafruit 8×8 NeoPixel Shield with Freescale FRDM-K64F Board

Mini Series Tutorial List


I’m starting here a mini series of articles how to use the FRDM-K64F board from Freescale with the Adafruit WS2812B LEDs (Adafruit named them ‘NeoPixels‘). I’m using the Freescale Kinetis Design Studio V3.0.0 (Eclipse based IDE with GNU ARM Embedded (launchpad)) with the Freescale Kinetis SDK. This first part covers how to set up the hardware.

Hardware Challenges

The WS2812B LEDs are RGB LEDs which have a built in-current driver with a shift register: I can chain the LEDs to long stripes and shift data to them.

There are several challenge with the WS2812B, both electrically and because of the special protocol needed by the WS2812:

  1. The NeoPixels need a 5V power supply. Each LED requires up to 60 mAin fulll (white) brightness (20 mA for each color (red, green and blue). Driving many LEDswill require a *lot* of current. For my larger projects I’m using multiple 5V 40A (!!!!!!) power supplies for my larger projects :-). 5V 40A Power Supply
  2. There needs to be large capacitor (1000 µF, 6.3V or higher) across the + and – terminals of the pixels. This prevents the initial onrush of current from damaging the pixels. That capacitor is not needed for a few (say 1-3) pixels, but definitely recommended for anything beyond, otherwise you risk to damage the pixels!
  3. The WS2812B logic level is 5V. As the FRDM-K64F board is using 3.3V, I need a very precise and fast (!) logic level shifter which translates the 3.3V to 5.0V, such as the 74AHCT125 or 74HCT245.
  4. The LEDs need a very precise timing. For each LED I need to shift 24 bits: first 8 bits for Green, then 8 bits for Red and finally 8 bits for Blue. A ‘1’ is encoded as 0.8 µs high, 0.45 µs low. A ‘0’ is 0.85 µs high, then 0.85 µs low. It is not (!!!) possible from normal C code to toggle a pin to reach that precision and timing, unless you are using well tuned assembly code.

To make it easier to connect WS2812 stripes, at the university we have developed a shield for FRDM or Arduino boards. The schematics and CAD files are open source and can be found on https://github.com/ErichStyger/mcuoneclipse/tree/master/Altium/NeoPixel%20Shield. As you very likely do not have that board :-(, I’ll describe how to do a similar thing with a bread board instead :-).

NeoPixel Shield for FRDM Boards

NeoPixel Shield for FRDM Boards

On another note: Using a high-speed logic analyzer or oscilloscope is *critical* for these kind of projects. If you do not have one, now it would be time to get one. Seriously! Doing such projects or finding problems without the right tools will be very, very frustrating, and every engineer or hobbyist should have the right tools on his bench :-).

I’m using the Logic16 (not available any more) and Logic Pro8) from Saleae (http://www.saleae.com). They are affordable and saved me countless hours of desperate debugging. The Logic4 is priced around $100 and would be good engough for this project. BTW: the Salea Logic16 was my Christmas present a couple of years ago (which I bought for myself) :-).

Probing FRDM-K64F with Logic Analyzer

Probing FRDM-K64F with Logic Analyzer

Hardware Setup

You need the following hardware:

  1. A Freescale Freedom board. I use the FRDM-K64F in this article. You can use any other board, but then you need to use potentially a different pin to talk to the LEDs.
  2. Any number of WS2812B/NeoPixels from Adafruit (http://www.adafruit.com/category/168).
  3. A good 5V power supply, depending on the amount of pixels/WS28122 you are using. E.g. the 5V 10A from Adafruit (http://www.adafruit.com/products/658). Consider as well a power jack to screw terminal adapter (http://www.adafruit.com/products/368)
  4. A good 3.3V to 5.0V level shifter. I recommend 74AHCT125 or 74HCT245 which are available in bread board friendly packages.
  5. A 300-500 Ohm resistor which is put into the DIN line to the LEDs
  6. A 1000 µF capacitor, rated at least 6.3V to be put between the 5V and GND.
  7. A bread board, necessary bread board wires and USB cables.

The image shows the wiring between the FRDM board , the level shifter and the NeoPixel LED’s.

Make sure you use the correct polarity of the capacitor!

Hardware Wiring

Hardware Wiring

In the picture I use a USB breakout board (http://www.adafruit.com/products/1833) connector as power supply: that way I can power a few LEDs from my laptop USB port (up to 500 mA) without the need for an external power supply, or using a wall USB power supply (I have one powering up to 2 A :-)).

Additionally, you might consider to use the 5V from the FRDM board. But do this *only* for very limited number of LED’s, as that 5V is very limited (check the schematics of your board!). I do *not* recommend that 5V, unless you are sure you are not damaging your board.

FRDM-K64F with NeoPixel WiringFRDM-K64F with NeoPixel Wiring

FRDM-K64F with NeoPixel Wiring with LEDsFRDM-K64F with NeoPixel Wiring with LEDs

FRDM-K64F with NeoPixel Wiring Top View

FRDM-K64F with NeoPixel Wiring Top View

Every Adafruit NeoPixel Board uses GND, 5V and DIN (Data IN). Connect these lines to the circuit described above. Solder wires or use headers where applicable. The picture shows a 8×8 NeoPixel Matrix on the left and a 8 pixel board stripe on the right:

NeoPixel Input Connector PointsNeoPixel Input Connector Points

I can chain multiple modules/strips with connecting the DOUT (Data OUT) to the DIN (Data IN) of the next module.

Connected 8x8 NeoPixel MatrixConnected 8×8 NeoPixel Matrix


This completes the hardware setup and wiring. It is important to use a good level shifter, a capacitor to limit the current rush plus a resistor on the input to the LEDs. Make sure you have a good power supply which is able to drive up to 60 mA per LED/Pixel. Multiple stripes and boards can be combined.

With this, the next article will describe how to get the software tools ready. So stay tuned…

iot ,freescale ,neopixel ,hardware

Published at DZone with permission of Erich Styger, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}