Hi all! I'm trying to control 8 LEDs (later up to 32) connected to a 12v source. I also want to be able to change their brightness. After some research, I decided to carry on with a TPIC6B595 Shift Register and PWM. The problem is that this is my very first project (I was just playing before with 74HC595), unlike for 74HC595, there are not many tutorials for TPIC6B595 and I can't figure out, where I make an error. I don't want anything complicated for the starters - just to light up a LED and be able to programmatically change its brightness. Could somebody please check if I have the circuit connected correctly and if my code is correct? Thank you very much!
// SRCRL of TPIC6B595
const int clearPin = 7;
// RCK of TPIC6B595
const int latchPin = 8;
// SRCK of TPIC6B595
const int clockPin = 6;
//// SER IN of TPIC6B595
const int dataPin = 9;
//// G of TPIC6B595
const int GPin = 12;
const byte testDigit = B10101010;
void setup() {
pinMode(clearPin, OUTPUT);
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(GPin, OUTPUT);
digitalWrite( clearPin, HIGH);
}
void loop() {
analogWrite(GPin, 240);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, testDigit);
digitalWrite(latchPin, HIGH);
delay(1000);
}
Thanks for a quick response LarryD! If I'll connect the Vcc pin on the Shift Register to the 5V pin on my Arduino, then the intensity of the LED will never change and will always stay at the max. brightness. I thought that if I'd like to control the brightness through the PWM, I need to disconnect the Vcc and control it through the G pin. Or is this incorrect?
My idea was to analogWrite to a G pin. I saw a similar example for 74HC595 and thought that it should also work here.
It might be easier but I already bought a bunch of TPIC6B595, which I believe I should also be able to achieve the same goal and it should be possible to change their brightness, if I'm not wrong.
Even with the 595, you can only change the state of any channel, one at a time.
So if you are say 50% PWM CH1, when you go to CH2 to PWM its output next, what will CH1 output be doing.
The only way I can see is to high frequency strobe the output channels, faster than the PWM frequency to keep the outputs independently updated "continuously".
To make it clear , you want to be able to give each output a different brightness level, or all the same?
If it is all LEDs the same brightness if you have them active, then the way you are going will work.