diff --git a/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino b/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino
index dd1724f602d..f3e45887576 100644
--- a/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino
+++ b/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino
@@ -60,6 +60,10 @@ bool setLightState(bool state, espHsvColor_t colorHSV) {
     analogWrite(ledPin, colorHSV.v);
 #endif
   } else {
+#ifndef RGB_BUILTIN
+    // after analogWrite(), it is necessary to set the GPIO to digital mode first
+    pinMode(ledPin, OUTPUT);
+#endif
     digitalWrite(ledPin, LOW);
   }
   // store last HSV Color and OnOff state for when the Light is restarted / power goes off
diff --git a/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino b/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino
index cb8b8b6f17f..79751905c20 100644
--- a/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino
+++ b/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino
@@ -56,6 +56,10 @@ bool setLightState(bool state, uint8_t brightness) {
     analogWrite(ledPin, brightness);
 #endif
   } else {
+#ifndef RGB_BUILTIN
+    // after analogWrite(), it is necessary to set the GPIO to digital mode first
+    pinMode(ledPin, OUTPUT);
+#endif
     digitalWrite(ledPin, LOW);
   }
   // store last Brightness and OnOff state for when the Light is restarted / power goes off
diff --git a/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino b/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino
index bd2d13899ca..8e12581fdf2 100644
--- a/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino
+++ b/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino
@@ -64,6 +64,10 @@ bool setLightState(bool state, espHsvColor_t colorHSV, uint8_t brighteness, uint
     analogWrite(ledPin, colorHSV.v);
 #endif
   } else {
+#ifndef RGB_BUILTIN
+    // after analogWrite(), it is necessary to set the GPIO to digital mode first
+    pinMode(ledPin, OUTPUT);
+#endif
     digitalWrite(ledPin, LOW);
   }
   // store last HSV Color and OnOff state for when the Light is restarted / power goes off
diff --git a/libraries/Matter/examples/MatterFan/MatterFan.ino b/libraries/Matter/examples/MatterFan/MatterFan.ino
index 1094126a843..705aa4853da 100644
--- a/libraries/Matter/examples/MatterFan/MatterFan.ino
+++ b/libraries/Matter/examples/MatterFan/MatterFan.ino
@@ -49,6 +49,10 @@ void fanDCMotorDrive(bool fanState, uint8_t speedPercent) {
   // drive the Fan DC motor
   if (fanState == false) {
     // turn off the Fan
+#ifndef RGB_BUILTIN
+    // after analogWrite(), it is necessary to set the GPIO to digital mode first
+    pinMode(dcMotorPin, OUTPUT);
+#endif
     digitalWrite(dcMotorPin, LOW);
   } else {
     // set the Fan speed
diff --git a/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino b/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino
index b814ba89704..d46427591ab 100644
--- a/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino
+++ b/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino
@@ -66,6 +66,10 @@ bool setLightState(bool state, uint8_t brightness, uint16_t temperature_Mireds)
     analogWrite(ledPin, brightness);
 #endif
   } else {
+#ifndef RGB_BUILTIN
+    // after analogWrite(), it is necessary to set the GPIO to digital mode first
+    pinMode(ledPin, OUTPUT);
+#endif
     digitalWrite(ledPin, LOW);
   }
   // store last Brightness and OnOff state for when the Light is restarted / power goes off