DEMO: APA102 RGB LED control via UCANS32K146 using Logitech F310
Last updated
Last updated
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.
For this demo you will need:
An APA102 based RGB LED "pixel led" board
UCANS32K146 or UCANS32K1SIC board
NAVQ board
Jumper wires
Shown below is a RGB LED headlight board (as used in ) with 10 leds numerated fom LED1 to LED10.
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.
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.
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:
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:
Connect to NavQPlus via a serial console or though ssh over Ethernet or Wifi. (See NavQPlus gitbook documentation for more details)
Ensure can-utils and Python are installed on NavQPlus, if not, install the required packages:
Then, reset and configure the NavQPlus CAN bus interfaces:
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.
<todo: change links from rudislabs to NXP>
Build the package:
run the following command in a bash terminal to automatically set up your ROS environment at startup of a bash terminal:
Then source your bashrc to ensure it is effective in the current session.
Now, run the following ROS command. It will install dependent packages:
After it runs re-source your bashrc and re-run the same launch script:
Open a second ssh session, and run the joy node to begin the connection with the joystick:
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.
10-LED "Headlight" | Signal | SPI Port (P1) Pin | UCAN Jumper wire color |
---|---|---|---|
Jumper wire color | UCAN/SPIRole |
---|---|
Black (original Wire)
PWR (5V)
SPI pin 1* or P11 'BEC PWR'
Red
Red
CLK
2
Yellow
Black (Added wire)
MOSI
4
Orange
White
GND
7
Black
Black
GND
Red
Power 5V
Yellow
Clock
Orange
MOSI (Data)