# RGB LED Strip not executing code

**URL:** <https://forum.arduino.cc/t/rgb-led-strip-not-executing-code/1185344>\
**Category:** General Guidance\
**Created:** [November 4, 2023, 8:23am UTC](https://forum.arduino.cc/t/rgb-led-strip-not-executing-code/1185344 "2023-11-04T08:23:34Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![codewalker77](https://avatars.discourse-cdn.com/v4/letter/c/e68b1a/32.png) [@codewalker77](https://forum.arduino.cc/u/codewalker77)\
**Post date:** [November 4, 2023, 8:23am UTC](https://forum.arduino.cc/t/rgb-led-strip-not-executing-code/1185344/1 "2023-11-04T08:23:34Z")

</div>

Hello everyone. The past few days I have been trying to get my contraption to work. I am trying to power up a 12V RGB LED strip using an Arduino MKR 1010 WiFi and a 12V power plug, with the appropriate resistors and transistors used. I will attach a picture of my circuit below.

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/4/3/4/434c1abb4dcbc7e2c387b323b2b610e96584b17f.png)

My Arduino board successfully connects to IOT Cloud (which is where I do my coding on, given this is an IOT Board), and the code even is shown to be successfully uploaded. I initially wanted to test my contraption, so I used a small test code as attached below:

```arduino
/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/6e50dd56-809d-4f30-acdd-0f7b830990d4 

  Arduino IoT Cloud Variables description

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

  float greenValue;

  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"
int greenPin=2;
int greenVal; 

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); 
  pinMode(greenPin,OUTPUT);

  // 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 
  
  analogWrite(greenPin,greenValue);
  Serial.println(greenValue);
  delay(1000);

}

/*
  Since GreenValue is READ_WRITE variable, onGreenValueChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onGreenValueChange() {
  // Add your code here to act upon GreenValue change
  analogWrite(greenPin,greenValue);
  Serial.println(greenValue);
  delay(1000);
}

```

My aim of this code was to control the brightness of one color of the LED directly from my phone, so I created a dashboard with greenValue as a slider from 0 to 255. Upon uploading the code, the RGB lights do not respond when the slider is moved, and I am sure that I have successfully connected to the wifi successfully. The LED just remains brightly on. I will also attach a picture of the specs of the RGB LED strip in use.

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/1/6/b/16b38cde65ff837f56274a2ad720a37056c4b020.png)

I hope you could help me out,  
thank you

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [November 4, 2023, 8:26am UTC](https://forum.arduino.cc/t/rgb-led-strip-not-executing-code/1185344/2 "2023-11-04T08:26:26Z")

</div>

What values of greenValue are you seeing printed ?

---

<div class="post-metadata">

**Author:** ![paulpaulson](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paulpaulson/32/363643_2.png) [@paulpaulson](https://forum.arduino.cc/u/paulpaulson)\
**Post date:** [November 4, 2023, 8:32am UTC](https://forum.arduino.cc/t/rgb-led-strip-not-executing-code/1185344/3 "2023-11-04T08:32:27Z")

</div>

You can follow a simple tutorial to operate an RGB Led strip, first.

---

<div class="post-metadata">

**Author:** ![PaulRB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paulrb/32/216330_2.png) [@PaulRB](https://forum.arduino.cc/u/PaulRB)\
**Post date:** [November 4, 2023, 8:32am UTC](https://forum.arduino.cc/t/rgb-led-strip-not-executing-code/1185344/4 "2023-11-04T08:32:36Z")

</div>

Upload the blink sketch, set for pin 2. Do the green LEDs flash?

What transistor did you use? Have you correctly identified the base, emitter, collector?

---

<div class="post-metadata">

**Author:** ![gilshultz](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gilshultz](https://forum.arduino.cc/u/gilshultz)\
**Post date:** [November 4, 2023, 3:14pm UTC](https://forum.arduino.cc/t/rgb-led-strip-not-executing-code/1185344/5 "2023-11-04T15:14:57Z")

</div>

Welcome! Why not post a simple schematic showing all of the connections and the EBC of the transistor. You did connect the grounds which is correct. How are you powering the Arduino? What transistor did you use? What is your load current?

---

<div class="post-metadata">

**Author:** ![anon85221860](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@anon85221860](https://forum.arduino.cc/u/anon85221860)\
**Post date:** [November 4, 2023, 3:37pm UTC](https://forum.arduino.cc/t/rgb-led-strip-not-executing-code/1185344/6 "2023-11-04T15:37:40Z")

</div>

You didn't mention which transistor you have.  
Perhaps you have the Collector and Emitter swapped?

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/c/5/1/c514ba1893e03b936912a6e6e61054fe54725696.png)

---

<div class="post-metadata">

**Author:** ![alto777](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/alto777/32/317385_2.png) [@alto777](https://forum.arduino.cc/u/alto777)\
**Post date:** [November 4, 2023, 3:54pm UTC](https://forum.arduino.cc/t/rgb-led-strip-not-executing-code/1185344/7 "2023-11-04T15:54:33Z")

</div>

> [@anon85221860](#):
>
> Perhaps you have the Collector and Emitter swapped?

There's no reason to know that the base is in the middle… and just trying different connection permutations is a recipe for destroying the device.

Use the part number and data sheet, or try something like

[https://electrocircuits.org/how-to-determine-transistor-terminals/](https://electrocircuits.org/how-to-determine-transistor-terminals/)

  

Also, are you sure it is a transistor? A recent thread had everyone busy while trying to make a temperature sensor part work, turned out to be a similar package but no a temp sensor at all.

a7

---

<div class="post-metadata">

**Author:** ![anon85221860](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@anon85221860](https://forum.arduino.cc/u/anon85221860)\
**Post date:** [November 4, 2023, 4:41pm UTC](https://forum.arduino.cc/t/rgb-led-strip-not-executing-code/1185344/8 "2023-11-04T16:41:43Z")

</div>

OK  
ahol777,  
Show me a TO-92 with its Base terminal on the outside.

---

<div class="post-metadata">

**Author:** ![alto777](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/alto777/32/317385_2.png) [@alto777](https://forum.arduino.cc/u/alto777)\
**Post date:** [November 4, 2023, 4:49pm UTC](https://forum.arduino.cc/t/rgb-led-strip-not-executing-code/1185344/9 "2023-11-04T16:49:40Z")

</div>

Here you go.

![image](https://europe1.discourse-cdn.com/arduino/original/4X/3/5/9/35917489cd299ae3a37f71f9eebc676c7a988f0e.png)

It's alto, BTW, if you mistyped that deliberately.

a7

---

<div class="post-metadata">

**Author:** ![anon85221860](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@anon85221860](https://forum.arduino.cc/u/anon85221860)\
**Post date:** [November 4, 2023, 5:03pm UTC](https://forum.arduino.cc/t/rgb-led-strip-not-executing-code/1185344/10 "2023-11-04T17:03:47Z")

</div>

Link to the datasheet

---

<div class="post-metadata">

**Author:** ![alto777](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/alto777/32/317385_2.png) [@alto777](https://forum.arduino.cc/u/alto777)\
**Post date:** [November 4, 2023, 5:06pm UTC](https://forum.arduino.cc/t/rgb-led-strip-not-executing-code/1185344/11 "2023-11-04T17:06:46Z")

</div>

It's even worse. Here's one that comes in two packages differentiated by an appended 'C'.

> **[ksc1008-d.pdf](https://www.onsemi.com/pdf/datasheet/ksc1008-d.pdf)**

  

I'm done. You?

a7

---

<div class="post-metadata">

**Author:** ![anon85221860](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@anon85221860](https://forum.arduino.cc/u/anon85221860)\
**Post date:** [November 4, 2023, 5:11pm UTC](https://forum.arduino.cc/t/rgb-led-strip-not-executing-code/1185344/12 "2023-11-04T17:11:17Z")

</div>

It shows two versions.  
And neither was the picture that you posted.

Maybe we can wait for the OP to get back to the topic.

---

<div class="post-metadata">

**Author:** ![codewalker77](https://avatars.discourse-cdn.com/v4/letter/c/e68b1a/32.png) [@codewalker77](https://forum.arduino.cc/u/codewalker77)\
**Post date:** [November 5, 2023, 12:09am UTC](https://forum.arduino.cc/t/rgb-led-strip-not-executing-code/1185344/13 "2023-11-05T00:09:48Z")

</div>

@ UK HeliBob in the serial monitor, the values are being printed accurately when changed from the dashboard.

@PaulRB , yes the green LEDs seem to flash, and I did correctly identify the base, emitter and collector, and tried it with multiple transistors, just to make sure I didn't blow up one. I am using an NPN transistor, identified using the number at the back.

@alto777 after trying the above with multiple transistors, at one point I just resorted to trying different permutations with the transistor. While my arduino board and pins work correctly as identified by the blink sketch, is it possible I blew the RGB LEDs?

I have tried my best to answer all of you. I sincerely appreciate your help.  
Thank you

---

<div class="post-metadata">

**Author:** ![mancera1979](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/mancera1979/32/732001_2.png) [@mancera1979](https://forum.arduino.cc/u/mancera1979)\
**Post date:** [November 5, 2023, 12:21am UTC](https://forum.arduino.cc/t/rgb-led-strip-not-executing-code/1185344/14 "2023-11-05T00:21:25Z")

</div>

You still have not said what transistor you are using…

---

<div class="post-metadata">

**Author:** ![TomGeorge](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tomgeorge/32/215261_2.png) [@TomGeorge](https://forum.arduino.cc/u/TomGeorge)\
**Post date:** [November 5, 2023, 12:26am UTC](https://forum.arduino.cc/t/rgb-led-strip-not-executing-code/1185344/15 "2023-11-05T00:26:14Z")

</div>

Hi, @codewalker77

Can you please post some pictures of your project?  
So we can see your component layout?

> [@codewalker77](#):
>
> I am using an NPN transistor, identified using the number at the back.

What is that number?

Do you have a DMM? Digital MultiMeter?

Thanks.. Tom.. 😀 👍 ☕ 🇦🇺

---

<div class="post-metadata">

**Author:** ![alto777](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/alto777/32/317385_2.png) [@alto777](https://forum.arduino.cc/u/alto777)\
**Post date:** [November 5, 2023, 1:30am UTC](https://forum.arduino.cc/t/rgb-led-strip-not-executing-code/1185344/16 "2023-11-05T01:30:21Z")

</div>

> [@codewalker77](#):
>
> is it possible I blew the RGB LEDs?

Can you test the strip independent of the code? From your diagram, something should light up if you remove the transistor and simply jump wire the former collector point to the emitter point.

If you were expecting the transistor to work to turn something on and off.

That's all the NPN transistor can do in that configuration - look like an open or more or less mostly closed switch.

a7

---

<div class="post-metadata">

**Author:** ![PaulRB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paulrb/32/216330_2.png) [@PaulRB](https://forum.arduino.cc/u/PaulRB)\
**Post date:** [November 5, 2023, 7:40am UTC](https://forum.arduino.cc/t/rgb-led-strip-not-executing-code/1185344/17 "2023-11-05T07:40:54Z")

</div>

> [@codewalker77](#):
>
> the green LEDs seem to flash

Good. They would only flash if your Arduino pin, the transistor and the led strip were all working and correctly connected.

> [@codewalker77](#):
>
> my arduino board and pins work correctly as identified by the blink sketch

Yes, and the green LEDs are also working.

> [@codewalker77](#):
>
> is it possible I blew the RGB LEDs?

Why do you ask that, you just reported that the strip was working?

---

<div class="post-metadata">

**Author:** ![codewalker77](https://avatars.discourse-cdn.com/v4/letter/c/e68b1a/32.png) [@codewalker77](https://forum.arduino.cc/u/codewalker77)\
**Post date:** [November 6, 2023, 6:27am UTC](https://forum.arduino.cc/t/rgb-led-strip-not-executing-code/1185344/18 "2023-11-06T06:27:49Z")

</div>

Hi Tom, here is the layout of my project.

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/8/0/6/806462828eca06bd6672cee767201787bf0f9505.jpeg)

Now the LED strip does not even light up. The transistor in use is a 2N3904. And the blink code, while it works for a normal LED, does not work for this strip. And I do not have a digital multimeter. Thank you for helping out!

---

<div class="post-metadata">

**Author:** ![codewalker77](https://avatars.discourse-cdn.com/v4/letter/c/e68b1a/32.png) [@codewalker77](https://forum.arduino.cc/u/codewalker77)\
**Post date:** [November 6, 2023, 7:02am UTC](https://forum.arduino.cc/t/rgb-led-strip-not-executing-code/1185344/19 "2023-11-06T07:02:59Z")

</div>

> [@alto777](#):
>
> From your diagram, something should light up if you remove the transistor and simply jump wire

Hello, yes the RGB LED does light up when I directly connect the power plug to the LED Strip terminals. However, it does not work in the contraption I have wired as shown  
Thank you for your time!

---

<div class="post-metadata">

**Author:** ![TomGeorge](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tomgeorge/32/215261_2.png) [@TomGeorge](https://forum.arduino.cc/u/TomGeorge)\
**Post date:** [November 6, 2023, 7:19am UTC](https://forum.arduino.cc/t/rgb-led-strip-not-executing-code/1185344/20 "2023-11-06T07:19:42Z")

</div>

Hi,

> [@codewalker77](#):
>
> I did correctly identify the base, emitter and collector,

[2n3903-d.pdf](https://forum.arduino.cc/uploads/short-url/g5qDhAKUtzBGyO1fPd6RqgDp79.pdf) (212.3 KB)

Please note; 2N3904

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/4/c/4/4c47c566cab6d075dbda32d89802d21c9ab39ed5.png)

 ![wrong](https://europe1.discourse-cdn.com/arduino/original/4X/3/1/d/31d02e17924e94899fab16d9e42b3f1ad48c09a8.jpeg)

You have collector to gnd instead of emitter.

Tom... 😀 👍 ☕ 🇦🇺

[Next page](https://forum.arduino.cc/t/rgb-led-strip-not-executing-code/1185344.md?page=2)
