RGB Project and FAN

Hello everybody,
I need to adapt this project carried out on Arduino Uno on an Arduino Nano 33 IoT.
All this for some reasons: I would like to be able to control the LEDs and the FAN both from the IR remote control and through Alexa. I have already tried with the ESP8266, but there are too many problems with the libraries not interfacing.
So I bought the Nano 33 IoT only I can’t understand anything about it, I don’t understand how I have to render the code, how it should be divided, what I have to put where and above all I don’t find RGB Example or Fan around on the web.
If I post my code, can someone adapt it to me?

This is the scheme of the project. The diagram shows 2 groups of 3 LEDs each (one on the right and one on the left). At the moment I considered only the 3 LEDs on the left, but then once I have seen how the code will come out I will study it and adapt it by making the appropriate changes

#include <IRremote.h>

#define FAN     6   // define the pin of the FAN
#define RX      12  // define the pin of the IR remote sensor

IRrecv irrecv(RX);         //  define and instantiate the infrared serial
decode_results results; // define the variable "results" to store the received button code


int fanSpeed=140;           // fan speed default starting
int fanSpeedPercent;
int red_light_pin = 11;
int green_light_pin = 10;
int blue_light_pin = 9;


void UP()    { fanSpeed=fanSpeed+5; analogWrite(FAN,fanSpeed); delay(100); } // function through which I increase the fan speed 
void DOWN()  { fanSpeed=fanSpeed-5; analogWrite(FAN,fanSpeed); delay(100); } //function by which I decrease the fan speed


void setup() {
  Serial.begin(9600);
  Serial.println("Starting IR-receiver...");
  irrecv.enableIRIn();                           // start the IR-receiver
  Serial.println("IR-receiver active");
  pinMode(red_light_pin, OUTPUT);
  pinMode(green_light_pin, OUTPUT);
  pinMode(blue_light_pin, OUTPUT);
  pinMode(FAN, OUTPUT);
  analogWrite(FAN, fanSpeed);  // default speed (between 0 and 255; example at 140)

RGB_color(255, 0, 0);      //RED
delay(500);

RGB_color(0, 255, 0);    //GREEN
delay(500);

RGB_color(0, 0, 255);       // BLUE
delay(500);

RGB_color(244, 70, 17);    // PURE ORANGE 602.72nm 
delay(500);

RGB_color(247, 94, 37);    //ORANGE RED LIGHT 598.71 nm
delay(500);

RGB_color(255, 69, 0);    // orangered HTML 602.98 nm
delay(500);

RGB_color(255, 35, 5);    //BRILLANT ORANGE 608.6 nm
delay(500);

RGB_color(255, 12, 0);    //SATUR RED 610.68nm
delay(500);

RGB_color(255, 117, 0);    //SATUR ORANGE 593.1 nm
delay(500);

RGB_color(230, 88, 25);    //ORANGE 597.87 nm
delay(500);

RGB_color(255, 54, 0);    //RED-ORANGE 605.64 nm
delay(500);
}

void loop()
{
     if (irrecv.decode(&results)) 
    { 
      (fanSpeed>90) && (fanSpeed<255);
        Serial.println(results.value, HEX); // Print the received value as a hexadecimal value
        irrecv.resume();    // Resume the IR-receiver to listen for new signals
        
        switch (results.value) // Determine which button has been pressed
          {
            case 0xE85952E1: RGB_color(255, 0, 0);// press a key on remote controller and obtain RED
            break;
            
            case 0x78CDA4DD: RGB_color(0, 255, 0);// press another key on remote controller and obtain GREEN
            break;

            case 0xA2672345: RGB_color(0, 0, 255); // press another key on remote controller and obtain BLUE
            break;

            case 0xB0F9B3E1: RGB_color(244, 70, 17); // press another key on remote controller and obtain ORANGE
            break;

            case 0x8503705D: if(fanSpeed<255)  UP();   // I press UP key and increase the speed of the FAN by 5        
            break; 


            case 0xDEB0C861: if(fanSpeed>90)    DOWN(); I press DOWN key and decrease the speed of the FAN by 5
            break; 
            default: ;
                           
          }
  }  
    delay(100);
    
    Serial.print("PWM VENTOLA: ");
    Serial.println(fanSpeed);
    fanSpeedPercent = map(fanSpeed,35,255,1,100);
    Serial.print("VELOCITA' VENTOLA: ");
    Serial.print(fanSpeedPercent);
    Serial.println(" %");
    delay(100);      // pause 100ms
}

void RGB_color(int red_light_value, int green_light_value, int blue_light_value)
{
  analogWrite(red_light_pin, red_light_value);
  analogWrite(green_light_pin, green_light_value);
  analogWrite(blue_light_pin, blue_light_value);
}

This is the code of Arduino Nano 33 IoT Cloud but it is empty because i don’t know how to compile. Can anyone help me?

In the project, since my utility and then that of interfacing with Alexa and giving the Voice commands I have seen that in the Dashboard and in the IoT variables only some are compatible with Alexa. Then :

  • for the fan I chose dimming light (the slider is unfortunately not compatible with Alexa I think :()
  • for the LEDs I entered the only dashboard compatible with the variable compatible with Alexa (I would have preferred the other of the colors but it did not indicate compatible with Alexa)
  • finally I inserted Sound that would be (but I still have to work on a background sound to reproduce in a speaker (even if this part could not be used)
/* 
  Sketch generated by the Arduino IoT Cloud Thing "LED"
  https://create.arduino.cc/cloud/things/71c0d9f4-93d9-40ba-a3fd-50a76dc4106c 

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  CloudSwitch sound;
  CloudColoredLight rgb;
  CloudDimmedLight fan;

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

#include "thingProperties.h"

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500); 

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
 */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();

}

void loop() {
  ArduinoCloud.update();
  // Your code here 
  
}


void onRgbChange() {
// Do something

}

void onSoundChange() {
  // Do something
}


void onFanChange() {
  // Do something
}

Thanks a lot to everyone!