This example demonstrates how to interface the WS2812B RGB LEDs on the Curiosity Nano Explorer Board using the PIC18F56Q24 Curiosity Nano. The WS2812B is an RGB LED that integrates both a control circuit and an RGB chip into a single package. It allows for easy control of multiple LEDs with a single data line, making it ideal for creating colorful lighting effects and displays.
In this project, the PIC18F56Q24 is configured to communicate with the WS2812B LEDs and generate various lighting patterns. The setup includes initializing the necessary peripherals, configuring the data output pin, and writing code to send the precise timing signals required to control the LEDs.
- MPLAB® X IDE 6.20.0 or newer (MPLAB® X IDE 6.20)
- MPLAB® XC8 3.00 or newer compiler (MPLAB® XC8 3.00)
- MPLAB® Code Configurator (MCC) 5.5.1 or newer (mplab-code-configurator)
- Microchip PIC18F-Q Series DFP (1.24.433) or newer (packs.download.microchip.com/)
- PIC18F56Q24 Curiosity Nano Evaluation Kit
- Curiosity Nano Explorer
- USB type C cable
The block diagram below shows how to connect the PIC18F56Q24 Curiosity Nano to the WS2812B LEDs on the Curiosity Explorer Board.
- Connect the PIC18F56Q24 MCU to the Curiosity Nano Explorer Board.
- Connect the PIC18F56Q24 MCU to your computer using a USB cable.
- Ensure that the WS2812B-RGB pin is connected to the data line of the WS2812B on the Curiosity Nano Explorer Board.
- Create a new project in MPLAB® X IDE and open MCC. If this is your first time using MCC, refer to Getting Started with MCU Projects Using MPLAB® Code Configurator (MCC) Melody - Developer Help
- Configure the output pin for the WS2812B LEDs, as shown in Figure 7.
- Write the code to generate the correct timing signals for the WS2812B LEDs.
- Compile and program the code into the PIC18F56Q24 MCU.
- Observe the lighting patterns and effects produced by the LEDs.
The userguide for the Curiosity Explorer Nano board provides detailed information about the pin mapping between the Curiosity Explorer board and the PIC18F56Q24 Curiosity Nano board being used in this example.
As shown in Figure 4 of the user guide above, pin IO27 on the Curiosity Nano Explorer Board is connected to the data line of the WS2812B LEDs.
The pin mapping for the PIC18F56Q24 Curiosity Nano Board can be found in the PIC18F56Q24 User Guide. Based on Figure 5 and Figure 6, pin IO27 on the Curiosity Nano Explorer Board is connected to the data line of the WS2812B LEDs. Ensure that the jumper is in place to connect the WS2812B-RGB pins on the Curiosity Nano Explorer Board. In this example project, the data line is connected to pin RE0 of the PIC18F56Q24 MCU. This pin must be configured as an output in MCC.
The pinout for the Curiosity Nano Socket located on the Curiosity Nano Explorer Board that is shown below can also be found in the userguide.
In MCC, select RE0 as the output pin, as shown in Figure 7 below. In the Pin Configuration window, RE0 is renamed to RGB, as illustrated below. All other MCC configurations remain at their default settings, as only one output pin needs to be added in this example. The next step after configuring the pin settings in MCC is to write the firmware to send the timing signals required to drive the WS2812B LEDs.
For the complete application code and a comprehensive description of the implementation, please refer to main.c.
After programming the device, the lighting patterns and effects created by the WS2812B LEDs should be observed. If the LEDs do not function as expected, ensure that:
- The output pin is correctly configured and connected to the data line of the WS2812B LEDs.
- The code is correctly generating the timing signals required by the WS2812B LEDs.
This document provides a guide for setting up and running an example project that demonstrates how to control WS2812B RGB LEDs using the PIC18F56Q24 MCU on the Curiosity Nano Explorer Board. It covers hardware setup, software configuration, and code implementation. The document includes links to related documentation, lists the required software and hardware, and outlines the features and prerequisites for the project. Step-by-step instructions are provided for configuring the output pin and writing the code to control the LEDs. Additionally, the document offers guidelines for verifying correct operation and troubleshooting any issues that may arise.