Addressable LEDs (WS2812) on ChipKIT

There has not been a simple addressable LED library for PIC32 microcontrollers until now! The PICxel library is an MPIDE library that handles the timing required to use addressable LEDs (WS2812, WS2811) or more commonly known as Adafruit Neopixels. Going through through a couple steps will allow your to get started with the PICxel library.Addressable LEDs (WS2812) on ChipKIT

What you will need:

  • Digilent chipKIT (UNO32 or UC32)
  • mini-USB cable
  • addressable LEDs (WS2812 or WS2811) I soldered female headers to the strip
  • a computer with MPIDE (covered later)
  • the PICxel library (also covered later)

What this will cover:

  • downloading and installing MPIDE
  • installing PICxel library
  • opening the demo
  • compiling and uploading the demo

WARNING – I am not responsible for damage caused to your LEDs by not heeding the following warnings!

  • 10 -15 LEDs at low brightness can be ran off of the microcontroller directly but either high intensity or higher numbers of LEDs can cause too much current draw for the microcontroller and an external power supply is required.
  • Adafruit strongly suggests adding a resistor about 470 ohm between the microcontroller data line and the LED data pin. I also strongly agree but haven’t used a resistor out of convenience and/or laziness.
  • Adafruit has the Adafruit Neopixel Uberguide that is a complete and detailed source for all possible questions and concerns dealing with addressable LEDs.

Step 1: Get and Install MPIDEGet and Install MPIDE

  1. Installing MPIDE is very simple. Simply download the compressed directory for your OS from here.
  2. extract the contents to a location of your choosing (I like to extract the package to the C: drive and right-click “create shortcut”. Then drag and drop the shortcut to the Windows start menu.
  3. Clicking on the shortcut from the start menu will open MPIDE like any other program

Further details on installing and using MPIDE can be found here.

Step 2: Get PICxel Library and Install Into MPIDEGet PICxel Library and Install Into MPIDE

The the PICxel library is available on Github. Downloading it is very simple.

  1. Click this link
  2. Open MPIDE
  3. Go to File -> preferences
  4. Take note of the “sketchbook location”
  5. Close MPIDE
  6. extract the PICxel library compressed file to the libraries folder in the “sketchbook location”
    1. if there is not a directory named “libraries” then create a folder named “libraries” (the folder name must be exactly “libraries”.
  7. Copy the PICxel-master folder into the libraries folder
  8. Rename the PICxel-master folder to “PICxel”
  9. Now the library is installed in MPIDE

Step 3: Running the DemoRunning the Demo

Now that the PICxel library is added to MPIDE we can run the demo and start having fun!

  1. Open MPIDE
  2. Go to File -> sketchbook -> libraries -> PICxel -> PICxel_demo
  3. The demo will open in the MPIDE text editor

Step 4: Connecting LEDs and ChipKIT

Once again, the demo in its current state is set to use less than full brightness. This is safe for 15 LEDs but for anymore then please consult the Adafruit NeoPixel Uberguide or build and use one of these: https://www.instructables.com/id/ChipKIT-Proto-Shie…

  1. Connect the ground wire from the LED strip to the GND terminal on the chipKIT
  2. Connect the 5V wire from the LED strip to the 5V0 terminal on the chipKIT
  3. Connect the data wire to PIN 0 of the chipKIT

The order of which the LEDs are connected is important to reduce the chance of damaging the LEDs.

Step 5: Setup and Upload the Demo to the ChipKITSetup and Upload the Demo to the ChipKIT

We need to setup MPIDE so that it knows which chipKIT board and what serial port it is on to program the microcontroller correctly.

  1. Open MPIDE
  2. Go to Tools -> Board -> chipKIT -> chipKIT UNO32 (or UC32)
  3. Go to Serial Port -> Comm port assigned to the chipKIT when plugged in
  4. Go to File -> Upload to board to compile and upload the program to the board.
  5. If “Done uploading” is displayed on the grey bar then your chipKIT has programmed successfully
    1. If not then you probably chose the wrong comm port in step 3. Try a different serial port and try again.

Step 6: Celebrate!

Now you can create awesome LED patterns using chipKIT!

Thanks for checking out my project.

I will be updating the PICxel library soon with added features.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter