TPIC6B595 no dimmer with PWM

Hello:

I am using Arduino Mega with TPIC6B595 the leds are working perfectly but I have connected the pin 9 (OE and this with ground) to pin 12 Arduino to get less brightness but the led bright full.
I am using Monitor Serial to send a number.

can you tell me what I am doing wrong please?
many thanks.

long i=0;


//Pin to clear the register
const int clearPin = 7;
//Pin connected to latch pin (RCK) of TPIC6B595
const int latchPin = 8;
//Pin connected to clock pin (SRCK) of TPIC6B595
const int clockPin = 6;
////Pin connected to Data in (SER IN) of TPIC6B595
const int dataPin = 9;

const int notG = 12; //not G PWM DIMMER

void setup() {
 //set pins to output because they are addressed in the main loop
 pinMode(clearPin, OUTPUT);
 pinMode(latchPin, OUTPUT);
 pinMode(dataPin, OUTPUT);  
 pinMode(clockPin, OUTPUT);
  pinMode(notG, OUTPUT);
  
 Serial.begin(9600);
 Serial.setTimeout(10);
 Serial.println("*");

 // Always start by setting SRCLR high
 digitalWrite( clearPin, HIGH);

 // delay a little and then set
 delay(100);
}

void loop() {
 

while (Serial.available()==0){}
    i=Serial.parseInt();
     Serial.println(i);

 analogWrite(notG, 10);
 // write to the shift register with the correct bit set high:
 registerWrite(i, HIGH);
 delay( 1000 );
 

}

// This method sends bits to the shift register:

void registerWrite(int whichPin, int whichState) {
 Serial.println(whichPin);
   
 // the bits you want to send
 byte bitsToSend = 0;
 // write number as bits
 bitWrite(bitsToSend, whichPin, whichState);

 // turn off the output so the pins don't light up
 // while you're shifting bits:
 digitalWrite(latchPin, LOW);
 Serial.println(bitsToSend);
 Serial.println("_");
 
 // shift the bits out
 shiftOut(dataPin, clockPin, MSBFIRST, bitsToSend);

 // turn on the output so the LEDs can light up:
 digitalWrite(latchPin, HIGH);
}

Well it is not the best way of doing a serial input, as soon as one byte arrives in the buffer you immediately try and convert the single byte into an integer. Leaving the next byte of the one input.

Read up on how to handle serial inputs.

Also try a analogue write of a much bigger number like 128, for a start.

I have used all numbers from 0 to 255 and the leds bright the same

Then you haven’t wired it up right.

cathode to Drain0
cathode to Drain1...
all anodes to resistor then to 5V.

When I send the number by serial to light every led is OK but no dimmer it

When I send the number by serial to light every led is OK but no dimmer it

OK so the LEDs are wired up correctly.

I have used all numbers from 0 to 255 and the leds bright the same

That means the signal is not getting to the ~OE pin of the chip, because a HIGH value (PWM 255) would turn off the LEDs and it clearly dosn't.

This is my schema.

I have not draw the SRCLR because there no space, but it is.

That is not a schematic it is a physical layout diagram, what is known here as Fritzing crap.

However I can see you have the LEDs wired wrong. Each LED should have its own resistor not one resistor for all LEDs. You also don't seem to have any decoupling capacitors. Also it seems you have shorted pin 12 to ground, so how can it ever go high?

We also need to see how you have wired it, so a photograph will tell us if the schematic ( when you post it ) matches what you have done.

I only need one resistor because I am using one led at a time, no two or more light on at the same time.

About the capacitor I didn't know that I need it. Where to put and what value?

and about shorted pin 12 to Ground is beacuse If I connect only the OE pin no light comes on, but when I connect to ground it works.
thank you

amjlopez:
I only need one resistor because I am using one led at a time, no two or more light on at the same time.

Actually, your Fritzing diagram and photo show that you have no resistor in series with the LEDs. No wonder you are having problems!

I only need one resistor because I am using one led at a time, no two or more light on at the same time.

OK but information that should have been in the first post.
Also if you take just a tiny bit more care with placing the wires you can obscure where all of them go not just most of them. Think about it could you follow the wiring from that photograph? The Fitzing crap shows you short out the resistor you think you have in the LEDs.

About the capacitor I didn't know that I need it. Where to put and what value?

0.1uF ceramic between the power pin and ground of the chip.

and about shorted pin 12 to Ground is beacuse If I connect only the OE pin no light comes on, but when I connect to ground it works.

So you ruin any chance of it working and perhaps damage the Arduino pin by putting a short circuit on it.

Try this:-
Remove the wire to pin 12
Output an LED so it is lit.
Remove the short, to the OE, the light should go out, if not connect it to 5V. So basically the LED is lit when the OE is connected to ground and not lit when it is open or connected to 5V.

Then remove the wire from the OE and connect up the wire to in 12, make sure you set the analogWrite to 128. If nothing happens then you have blown your Arduino pin. Try another PWM capable pin, remember to change your code accordingly.

Yes, you are reason. I made the image with Photoshop, no Fritzing (I don't know it), sorry.

The Fitzing crap shows you short out the resistor you think you have in the LEDs.

the resistor is not well placed? please, can you tell how to put it?

Output an LED so it is lit.

From where to where do I must put the led?

thanks

amjlopez:
the resistor is not well placed? please, can you tell how to put it?

Well, you have to put it in series with the LEDs.

amjlopez:
From where to where do I must put the led?

Once you have the resistor in series with the LEDs, write code to set the output of the TPIC6B595 to one of the LEDs you already have, active.

I have put all anodes together and one resistor for all them. As I said before, I only lit one led at a time.
Is this not the correct way to do it?
If not, please can you tell me how to connect them?
thanks

I have put all anodes together and one resistor for all them.

You have not got ANY resistor in series with the LEDs, you short out that resistor with the power track on your solderless breadboard.

OK. I don't know how to put the resistor in serie for all leds, can you draw me how to do it please?

This is very silly. It almost suggests that you are exceeding your current skill set and need to do some more basic circuits.

You put the resistor between the bottom red line and one of the vertical lines above it. Then you put the link to the top red line to one of the five holes vertical line you put the resistor to.

Time to do some homework How to Use a Breadboard - SparkFun Learn

Two more things:

Well it is not the best way of doing a serial input, as soon as one byte arrives in the buffer you immediately try and convert the single byte into an integer. Leaving the next byte of the one input.

I need to send an integer with two digits for example:35 and then lit the corresponding led.
If this is not the best way to do it, please, can you tell me how?

Another question, I have to use 4 more TPIC6B595 do I have to put one capacitor in every TPIC6B595?

Another question, I have to use 4 more TPIC6B595 do I have to put one capacitor in every TPIC6B595?

Yes.

I need to send an integer with two digits for example:35 and then lit the corresponding led.

I thought you said your code was working in that respect?

Well it is not the best way of doing a serial input, ...

Yes, but you told me this is not the best way to read serial data. Which is a better way?
thank you