How to use 'Switch' in the ColoredLight widget

Hi,
I am testing the Colored Light widget and I have the problem of using the 'on/off' switch to turn the leds off and on. What happens to me is that the leds are always on and I can't switch them off with the button. I can only switch them off if I set the slider to ZERO.
I have added some program lines in the sketch to use the switch but it gives me this error:

Start verifying
In file included from /home/builder/Arduino/libraries/fastled_3_6_0/src/FastLED.h:75,
                 from /tmp/2491589689/TestWS2812B_apr02a/TestWS2812B_apr02a.ino:18:
/home/builder/Arduino/libraries/fastled_3_6_0/src/fastspi.h:157:23: note: #pragma message: No hardware SPI pins defined.  All SPI access will default to bitbanged output
 #      pragma message "No hardware SPI pins defined.  All SPI access will default to bitbanged output"
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/2491589689/TestWS2812B_apr02a/TestWS2812B_apr02a.ino: In function 'void onLEDstripChange()':
/tmp/2491589689/TestWS2812B_apr02a/TestWS2812B_apr02a.ino:63:6: error: 'lEDtrip' was not declared in this scope
     (lEDtrip, LOW)
      ^~~~~~~
/tmp/2491589689/TestWS2812B_apr02a/TestWS2812B_apr02a.ino:63:6: note: suggested alternative: 'lEDstrip'
     (lEDtrip, LOW)
      ^~~~~~~
      lEDstrip
Multiple libraries were found for "WiFi.h"
  Used: /home/builder/.arduino15/packages/esp32/hardware/esp32/2.0.5/libraries/WiFi
  Not used: /home/builder/opt/libraries/wifiespat_1_4_3
  Not used: /home/builder/opt/libraries/vega_wifinina_1_0_1
  Not used: /home/builder/opt/libraries/wifinina_1_8_14
  Not used: /home/builder/opt/libraries/nina_wi_fi_1_0_1
  Not used: /home/builder/opt/libraries/seeed_arduino_rpcwifi_1_0_7
  Not used: /home/builder/opt/libraries/wifi_1_2_7
  Not used: /home/builder/opt/libraries/indhilib_3_0_5
  Not used: /home/builder/opt/libraries/da16200_wi_fi_library_for_arduino_1_1_0
Multiple libraries were found for "WiFiClientSecure.h"
  Used: /home/builder/.arduino15/packages/esp32/hardware/esp32/2.0.5/libraries/WiFiClientSecure
  Not used: /home/builder/opt/libraries/seeed_arduino_rpcwifi_1_0_7
Error during build: exit status 1

In file included from /home/builder/Arduino/libraries/fastled_3_6_0/src/FastLED.h:75,
                 from /tmp/2491589689/TestWS2812B_apr02a/TestWS2812B_apr02a.ino:18:
/home/builder/Arduino/libraries/fastled_3_6_0/src/fastspi.h:157:23: note: #pragma message: No hardware SPI pins defined.  All SPI access will default to bitbanged output
 #      pragma message "No hardware SPI pins defined.  All SPI access will default to bitbanged output"
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/2491589689/TestWS2812B_apr02a/TestWS2812B_apr02a.ino: In function 'void onLEDstripChange()':
/tmp/2491589689/TestWS2812B_apr02a/TestWS2812B_apr02a.ino:63:6: error: 'lEDtrip' was not declared in this scope
     (lEDtrip, LOW)
      ^~~~~~~
/tmp/2491589689/TestWS2812B_apr02a/TestWS2812B_apr02a.ino:63:6: note: suggested alternative: 'lEDstrip'
     (lEDtrip, LOW)
      ^~~~~~~
      lEDstrip
Multiple libraries were found for "WiFi.h"
  Used: /home/builder/.arduino15/packages/esp32/hardware/esp32/2.0.5/libraries/WiFi
  Not used: /home/builder/opt/libraries/wifiespat_1_4_3
  Not used: /home/builder/opt/libraries/vega_wifinina_1_0_1
  Not used: /home/builder/opt/libraries/wifinina_1_8_14
  Not used: /home/builder/opt/libraries/nina_wi_fi_1_0_1
  Not used: /home/builder/opt/libraries/seeed_arduino_rpcwifi_1_0_7
  Not used: /home/builder/opt/libraries/wifi_1_2_7
  Not used: /home/builder/opt/libraries/indhilib_3_0_5
  Not used: /home/builder/opt/libraries/da16200_wi_fi_library_for_arduino_1_1_0
Multiple libraries were found for "WiFiClientSecure.h"
  Used: /home/builder/.arduino15/packages/esp32/hardware/esp32/2.0.5/libraries/WiFiClientSecure
  Not used: /home/builder/opt/libraries/seeed_arduino_rpcwifi_1_0_7
Error during build: exit status 1

The sketch is this:

#include "arduino_secrets.h"
  /* 
    Sketch generated by the Arduino IoT Cloud Thing "Untitled"
    https://create.arduino.cc/cloud/things/15de016d-ca87-4950-ba15-033e29aa2b3c 
  
    Arduino IoT Cloud Variables description
  
    The following variables are automatically generated and updated when changes are made to the Thing
  
    CloudColoredLight lEDstrip;
  
    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"
  #include <FastLED.h>
    
    #define NUM_LEDS 3
    #define LED_PIN 2 // pin out signal
    
    CRGB leds[NUM_LEDS];
    
    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);
    
    FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
    
    // Defined in thingProperties.h
    initProperties();
    
    // Connect to Arduino IoT Cloud
    ArduinoCloud.begin(ArduinoIoTPreferredConnection);
    
    setDebugMessageLevel(2);
    ArduinoCloud.printDebugInfo();
    }
    
    void loop() {
    ArduinoCloud.update();
    // Your code here
    }
    
    /*
    Since LEDstrip is READ_WRITE variable, onLEDstripChange() is
    executed every time a new value is received from IoT Cloud.
    */
    void onLEDstripChange() {
    uint8_t r, g, b;
    lEDstrip.getValue().getRGB(r, g, b);
    
    for (int i = 0; i < NUM_LEDS; i++) {
    leds[i] = CRGB(r, g, b);
    }
    //check if switch is on/off 
    if (lEDstrip.getSwitch()) {
    }
    else {
      (lEDtrip, LOW)
    }
      FastLED.show();
    }

Need help

EzioGi

Could you explain, what you try to achieve with this lines?

Hi @eziogi.

You misspelled the variable name (note the missing s in lEDtrip).

I would like to use the switch in the Coloured Light to switch the LEDs on and off, without having to set the brightness slider to zero.

EzioGi