loading

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.

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 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 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 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 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.

<p>If you get an error with MPIDE that says, &quot;Cannot use PICxel_libs-master&quot; must contain only ASCII characters... go to the file and delete the &quot;-master&quot; (this is a weird github thing). Then close and reopen MPIDE. </p>
<p>Have you tried the library with multiple strings of leds on different pins at once (ie declaring the library multiple times using different pins/names)?</p>
<p>I have not tried running multiple strings off of one board. As it stands, the library should be able to do this if the pins are not on the same port register. I will try to update to have this functionality this weekend. Thanks for the question!</p>
<p>Thanks for that, good point, 'same port register'. Maybe that's why using pin 3,5&amp;6 doesn't work for me. Something to look at this morning :)</p>
<p>yah......pin 3, 5 and 6 are all on port d. So if you are having issues running the bitstream out of those pins then that would explain that. I would suggest pin 3, 13 and 28. Those pins are on different ports and that will provide a simple solution for now. I will try to add code to allow for pins on the same port. If you are not sure about what I mean about ports, then you could check out the PIC32 reference manuals OR this.....when MPIDE or Arduino define pins, it is refering to a specific bit of a port register on the microcontroller. So, pins 3,5 and 6 correspond to PORTD bits 0, 1 and 2. You can check out the port to pin mapping from the schematic here: http://digilentinc.com/Data/Products/CHIPKIT-UC32/chipKIT%20uC32_bysa_a_sch.pdf</p>
<p>That would be very useful (&quot;I will try to add code to allow for pins on the same port.&quot;). We're breaking up the strings because of distance so will have 12 strings in total. Works on the arduino with the adafruit library, but can't do anything to fancy like FFT and a few others plus drive 500+ LED's hence the chipKIT :-) Not sure yet if we've bitten of more than we can chew though. :-)</p>
<p>I updated the library with a fix that will allow multiple strands of LEDs to run off of the same board. You can check it out on my Github. Please leave me details on how it works?</p>
<p>Hi, did you commit it to GitHub? The files there at the moment are still the same from 2 months ago. (I've done that too :) ) I'm looking at <a href="https://github.com/mwingerson/PICxel_libs" rel="nofollow">https://github.com/mwingerson/PICxel_libs</a></p>
<p>Please check again. The update looks to be there. Sorry about the delay, I am adjusting to having class again.</p>
<p>Thanks for the shout out :-)</p>

About This Instructable

7,534views

44favorites

License:

Bio: Check out my up coming microcontroller board! www.redlemur.io
More by mwingerson:Addressable LEDs on the Arty FPGA board Reflow Toaster Oven Addressable LEDs (WS2812) on chipKIT 
Add instructable to: