LED not controlled by switch widget on dashboard

knock knock knock
Dear gentlemen, I would like to ask for your help.
Although my English is short, I would like to ask for a helping hand because of the frustration of an unresolved problem.

The board used is 'Arduino Nano rp2040 connect'.

I want to control red, green, and blue of boolean type using 'switch' on the dashboard.
Red, green, blue correspond to onboard rgb led.

The source code used is below.

#include "thingProperties.h"

void setup() {
  // Initialize serial and wait for port to open:
  pinMode(LEDR, OUTPUT);
  pinMode(LEDG, OUTPUT);
  pinMode(LEDB, OUTPUT);

  Serial.begin(9600);
  
  while(!Serial); // Prevents sketch from running until Serial Monitor opens.
  
  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();
  
  ArduinoCloud.addCallback(ArduinoIoTCloudEvent::CONNECT, onIoTConnect);
  ArduinoCloud.addCallback(ArduinoIoTCloudEvent::DISCONNECT, onIoTDisconnect);
  ArduinoCloud.addCallback(ArduinoIoTCloudEvent::SYNC, onIoTSync);
}

void loop() {
  ArduinoCloud.update();
  //reads acceleration
}


void onRedChange() {
  if(red){
    digitalWrite(LEDR, HIGH); //turn on RED
  }
  else{
    digitalWrite(LEDR, LOW); //turn off RED
  }
}


void onGreenChange() {
  if(green){
    digitalWrite(LEDG, HIGH); //turn on GREEN
  }
  else{
    digitalWrite(LEDG, LOW); //turn off GREEN
  }
}


void onBlueChange() {
  if(blue){
    digitalWrite(LEDB, HIGH); //turn on BLUE
  }
  else{
    digitalWrite(LEDB, LOW); //turn off BLUE
  }
}

void onIoTConnect() {
	Serial.println(">>> connected to Arduino IoT Cloud");
}
void onIoTDisconnect() {
	Serial.println(">>> disconnected to Arduino IoT Cloud");
}

void onIoTSync() {
	Serial.println(">>> Board and Cloud SYNC OK");
}

After opening the Serial Monitor and displaying the "SYNC OK" message, the LED's color is determined according to the value you set on the dashboard.

However, the status of the LED does not change even if I further control the 'switch' on the dashboard afterwards.

Since the variable was normally assigned to the 'switch', it is confirmed that the value has changed in the 'Variables' in the 'Setup' tab.

'Variable Permission' is also set to 'Read & Write'.

If there is a cause that can control this abnormality, please advise.

Thank you so much for reading this far.

Hey. Did you solve your problem?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.