DEMO: APA102 RGB LED control via UCANS32K146 using Logitech F310


This tutorial aims to explain how to connect an APA102 based RGB LED "pixel led" board and control light intensity via a Joystick with ROS2.

Items needed

For this demo you will need:

  • An APA102 based RGB LED "pixel led" board

  • UCANS32K146 or UCANS32K1SIC board

  • NAVQ board

  • Jumper wires

Daisy chain connection of APA102 LEDs

The 10-LED PCB board has 4 wired connections: DATA CLK, PWR, GROUND. The DATA line(wire) of the board connects to the Data_in of the first LED. Each LED is daisy chained to the next from Data_out pin of one to Data_IN of the next, and so on.

There are other APA102 LED boards that might be used. For example there are 3-LED boards also on El Mandadero. These boards can also daisy chain from one board to the next. From the software point of view these are just considered one long string of LEDs.

Connecting the LED board to the UCAN board.

The 10-LED "headlight board" shown here is built from an American standard taillight. The internal board has been changed from a simple "on-bright, on-dim" direct DC wiring to the digital connection to these RGB LEDs. Therefore an extra black wire was added to the plastic assembly.

10-LED "Headlight"SignalSPI Port (P1) PinUCAN Jumper wire color

Black (original Wire)

PWR (5V)

SPI pin 1* or P11 'BEC PWR'






Black (Added wire)








Arbitrary colored jumper wires were used to connect between the 10=LED headlight board and the SPI port pin header on the UCAN board. The colors used on the UCAN side were as follows:

Jumper wire colorUCAN/SPIRole




Power 5V




MOSI (Data)

The wires on the UCAN board are shown connected in the following image:

NOTE that the color codes above are non-standard. They should be checked when any different LED boards are being connected.

NOTE that the power 5V may also PREFERRABLY be supplied by using the servo 5V output and providing external 5V power from the BEC header (BEC = 5V DCDC converter) See below for board reference:

Software procedure

Connect to NavQPlus via a serial console or though ssh over Ethernet or Wifi. (See NavQPlus gitbook documentation for more details)

CAN tools

Ensure can-utils and Python are installed on NavQPlus, if not, install the required packages:

sudo apt-get update 
sudo apt-get dist-upgrade 
sudo apt-get install can-utils 
pip install python-can 

Configure CAN bus

Then, reset and configure the NavQPlus CAN bus interfaces:

pkill python3 
sudo ip link set can1 down 
sudo ip link set can0 down 
sudo ip link set can0 up type can bitrate 1000000 loopback off restart-ms 100 
sudo ip link set can1 up type can bitrate 1000000 dbitrate 4000000 loopback off fd on fd-non-iso off restart-ms 100 

ROS2 setup

If not already installed, Install ros2_orchestrator ROS packages from GitHub.

You need to set up your ssh keys for GitHub. If you want to use your token, just change the ssh URLs to HTTPS URLs.

mkdir -p ~/git/ros2/src 
cd ~/git/ros2/src 
git clone 

<todo: change links from rudislabs to NXP>

Build the package:

colcon build --symlink-install 

run the following command in a bash terminal to automatically set up your ROS environment at startup of a bash terminal:

sudo echo "source /home/$USER/git/ros2/install/setup.bash" >> ~/.bashrc

Then source your bashrc to ensure it is effective in the current session.

source ~/.bashrc 

Now, run the following ROS command. It will install dependent packages:

ros2 launch ros2_orchestrator 

After it runs re-source your bashrc and re-run the same launch script:

ros2 launch ros2_orchestrator 

Open a second ssh session, and run the joy node to begin the connection with the joystick:

ros2 run joy joy_node 

Operation of the demo

Now your LEDs are ON and you should be able to control the light intensity.

Use the left and right buttons of the joystick (buttons in front of the device - see picture below) to play with the colors.

Last updated