Problem with connecting LED STRIP 5volt

First off all, hello ladies and gentleman.

I am a new commer to this world, i understand a bit of programming languages and logics, but i am struggling with a problem connecting a LED strip that i bough on a store, with a 5v charger( that also means i can use it from arduino directly ( i think).
Those fotos shows as 4.5 Volts, but my is 5v!

My problem is:

http://postimg.org/image/47ge3uu9d
(in case the link is dead for “some reason” you can find it also here)

is shows 4 inputs, 5v, R, G, and B.

i connect 5V to 5V from arduino, and i am using the R G B as a “way” to ground through arduino… ( maybe this is my failure here, i don´t know)

everything is working with my code, BUT, it turns just ON or OFF, and the analogWrite is working on the oposite as it should… for example if i write

analogWrite(LED_G,255);

it turns OFF

and

analogWrite(LED_G,0);

it turns ON

which in someway makes sence… “someway” because it is connected on the oposite…

anyway, i didnt though this could be a big issue, until i decided to try to make colours using the dim of the LED…well… it just doesn´t work… well… kind of

  • Serial.println(“More”);*

  • Serial.println(“255”);*
    analogWrite(LED_G,255); LED turns OFF ( if on)
    Serial.println(analogRead(LED_G)); shows 1022 on SERIAL

  • delay(1000);*

  • Serial.println(“0”);*
    analogWrite(LED_G,0); LED IS ACTUALLY ON
    Serial.println(analogRead(LED_G)); shows 334 on SERIAL

  • delay(1000);*

  • Serial.println(“125”);*
    analogWrite(LED_G,125); LED IS ACTUALLY ON
    Serial.println(analogRead(LED_G)); ** shows 335 on SERIAL**

  • delay(1000);*

  • Serial.println(“150”);*
    analogWrite(LED_G,150); LED IS ACTUALLY OFF
    Serial.println(analogRead(LED_G)); shows 1021 on SERIAL

  • delay(1000);*

  • Serial.println(“200”);*
    analogWrite(LED_G,200); it stays always OFF after "150"

  • Serial.println(analogRead(LED_G));*

  • delay(1000);*

I my best guess would be around the circuit itself and not the code… but this was already a “debug” phase…let´s call it that way.

electronics is not my real thing, so i maybe need some help on that subject.

thanks for the help guys, i already tryed to find on google help on this matter, but i am only able to find LED STRIPS with more then 5v, so its not really helpfull, because i dont want to use any kind of relays or so.

Sorry also for my english, it is not my main language.

Thanks for any help or tip.

code.txt (2.26 KB)

Post your code.
Use code tags.

analogWrite(LED_G,150);                LED IS ACTUALLY OFF            
        Serial.println(analogRead(LED_G));

What is the value of LED_G?

Code is here, sorry.

#include <IRremote.h>

#define BLUE 0x40BECA35
#define RED 0x40BEE817
#define GREEN 0x40BE08F7
#define ALL_OFF 0x40BE6A95
#define MORE 0x40BE8A75
#define LESS 0x40BE48B7


#define LED_G A0 // choose the pin for the LED
#define LED_B A1 // choose the pin for the LED
#define LED_R A2 // choose the pin for the LED
#define brilho_passo 50

#define RECV_PIN 11

int state_B = 255;
int state_R = 255;
int state_G = 255;


IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver

  pinMode(LED_G,OUTPUT);
  pinMode(LED_R,OUTPUT);
  pinMode(LED_B,OUTPUT);

}

void loop() {
  if (irrecv.decode(&results)){
    Serial.println(results.value, HEX);
    
    switch(results.value)
    {
      case MORE:
      {


        Serial.println("More");
        Serial.println("255");
        analogWrite(LED_G,255);
        Serial.println(analogRead(LED_G));
        delay(1000);
        
        Serial.println("0");
        analogWrite(LED_G,0);
        Serial.println(analogRead(LED_G));
        delay(1000);
        
        Serial.println("125");
        analogWrite(LED_G,125);
        Serial.println(analogRead(LED_G));
        delay(1000);
        
        Serial.println("150");
        analogWrite(LED_G,150);
        Serial.println(analogRead(LED_G));
        delay(1000);
        
        Serial.println("200");
        analogWrite(LED_G,200);
        Serial.println(analogRead(LED_G));
        delay(1000);

        break;
      }

      case LESS:
      {

        break;
      }
      
      case GREEN :
      {
        Serial.println("vem aki? verde");
       analogWrite(LED_G,0);
       
       break;
      } 
      case BLUE :
      {
        Serial.println("vem aki? azul");
       analogWrite(LED_B,0);
       
       break;
      }
       case RED :
      {
        Serial.println("vem aki? vermelho");
       analogWrite(LED_R,0);
       
      break;
      }
      default:
      
        Serial.println("vem aki? todos 255");
      analogWrite(LED_G,255);
      analogWrite(LED_B,255);
      analogWrite(LED_R,255);
      
    }
    

  delay(200);
  
  irrecv.resume(); // Receive the next value
}
  
}

My serial shows this:

More
255
1023
0
337
125
339
150
1023
200
1023

So you're trying to use the analogue pins LED_R etc as both inputs and outputs?

shouldn't it be an output?

just changed ( for curiosity)

pinMode(LED_G,INPUT);

Serial shows this:

More
255
1023
0
337
125
338
150
1022
200
1023

and results are the same.

when i do analogRead, if to know how is it "shinning"

OK, let's assume that A0 is an output, because that's what you set it to be in setup().
But it's not a PWM output, so an analogWrite to it will be off for values less than 128 and on for values equal to or greater than 128.

hmm.. well it works with a PWM output, i notice that it only will work with 6,5,3 because of that ~ ( i would say) .. anyway it works the way i want :slight_smile: thanks AWOL

you can close this if you want