Previously I posted on this forum as I was having trouble converting the gas sensor ADC value to voltage.
That problem has since been fixed, although I seem to be running into a new issue where my WS2812 RGB LED won't turn on, and the PuTTy monitor is outputting a incorrect value for my gas sensor. Here is the digikey link of the RGB LED that I am using: https://www.digikey.com/en/products/detail/inolux/IN-PI554FCH/7604874.
The code that I referenced for the RGB LEDs can be found from this Youtube video: https://www.youtube.com/watch?v=-3VKkTSAytM&t=1389s.

Here is a picture of my IOC setup, I have PB15 tied to the signal pin of my RGB LED and 5V and GND to it connected on my breadboard
Here is the SPI Header File code (The outer brackets are just to keep the code neat and not included in the actual SPI):
[
#ifndef INC_IN_PI554FCH_SPI_H_
#define INC_IN_PI554FCH_SPI_H_
void SetLED (int led, int RED, int GREEN, int BLUE);
void RGB_Send(void);
#endif /* INC_IN_PI554FCH_SPI_H_ */
]
Here is the SPI C code:
[
/*
* IN-PI554FCH.c
*
* Created on: Dec 24, 2023
* Author: ricci
*/
#include "main.h" //Include main header file in project repository
#include "IN-PI554FCH_SPI.h" //Include custom RGB header file (Clone of WS2813Bs)
#define NUM_LED 1 //Define the # of RGB LEDs being used as 1
uint8_t LED_Data[NUM_LED][4]; //Create a matrix array to store the three colors for each LED
extern SPI_HandleTypeDef hspi2; //Defines SPI handler as an external variable
void SetLED (int led, int RED, int GREEN, int BLUE) //Function to set the colors for each LED
{
LED_Data[led][0] = led;
LED_Data[led][1] = GREEN;
LED_Data[led][2] = RED;
LED_Data[led][3] = BLUE;
}
void RGB_spi(int GREEN, int RED, int BLUE) //Send data through the SPI using the color codes
{
uint32_t color = GREEN<<16 | RED<<8 | BLUE; //Combine the 3 color bytes to make single 24 bit data
uint32_t SendData[24]; //Creates an array of 25 bytes to send the data to the SPI
int index = 0; //Variable used to keep track of how many bytes are occupied in the array
for (int i=23;i>=0;i--)//Shift the color data by 23 bits to the right, then to extract that position
{
if(((color>>i)&0x01)==1)SendData[index++]=0b110; //If the bit is a 1, store 110 in the 1st element of the array,
//otherwise will store 100 in an array, shifting the color data 22
//places to extract the 2nd bit from the end
else SendData[index++]=0b100;
}
HAL_SPI_Transmit(&hspi2, SendData, 24, 1000);
}
void RGB_Send (void) //Function calls from the main file to send the data to each LED being used
{
for(int i=0; i<NUM_LED; i++) //For loop is called as many times as the # of LEDs in the system
{
RGB_spi(LED_Data[i][1], LED_Data[i][2], LED_Data[i][3]); //Sends data for each individual LEDs
}
}
]