# Basic set-up for TPIC6B595 Shift Register with PWM

**URL:** <https://forum.arduino.cc/t/basic-set-up-for-tpic6b595-shift-register-with-pwm/1072907>\
**Category:** LEDs and Multiplexing\
**Created:** [January 4, 2023, 1:55am UTC](https://forum.arduino.cc/t/basic-set-up-for-tpic6b595-shift-register-with-pwm/1072907 "2023-01-04T01:55:35Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![dworza](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/dworza/32/906426_2.png) [@dworza](https://forum.arduino.cc/u/dworza)\
**Post date:** [January 4, 2023, 1:55am UTC](https://forum.arduino.cc/t/basic-set-up-for-tpic6b595-shift-register-with-pwm/1072907/1 "2023-01-04T01:55:36Z")

</div>

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!

```cpp
// 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);
}

```

[Here is a diagram of my circuit](https://imgur.com/NjNX5yI)

[Here is a photo of my circuit](https://imgur.com/ixkEx7M)

---

<div class="post-metadata">

**Author:** ![LarryD](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/larryd/32/215550_2.png) [@LarryD](https://forum.arduino.cc/u/LarryD)\
**Post date:** [January 4, 2023, 1:59am UTC](https://forum.arduino.cc/t/basic-set-up-for-tpic6b595-shift-register-with-pwm/1072907/2 "2023-01-04T01:59:36Z")

</div>

There is no power connection to the I.C.

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/8/0/7/80780c22e50da396e07300f108de9547370089b2.jpeg)

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/9/5/2/95254143094a96394395b141ba905b82fd72b5f8.jpeg)

---

<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:** [January 4, 2023, 2:05am UTC](https://forum.arduino.cc/t/basic-set-up-for-tpic6b595-shift-register-with-pwm/1072907/3 "2023-01-04T02:05:27Z")

</div>

Hi, @dworza  
Welcome to the forum.

Thanks for using code tags.. 👍 👍

> [@dworza](#):
>
> decided to carry on with a TPIC6B595 Shift Register and PWM.

How do you aim to PWM through a shift register?  
This would be better and easier to code.

> **[Adafruit 24-Channel 12-bit PWM LED Driver - SPI Interface - TLC5947](https://core-electronics.com.au/adafruit-24-channel-12-bit-pwm-led-driver-spi-interface-tlc5947.html?gclid=CjwKCAiAwc-dBhA7EiwAxPRylBSuKqZh85YKM5jeNat584Fn3gMv2HRMoUvnQLUx4Pw720I6fgvN8RoCYJsQAvD_BwE)**
>
> For all of you out there who want to control 24 channels of PWM, Adafruit salute you! They also would like you to check out this breakout board for the TLC5947 PWM driver...

There is also a Library for it.

> **[TLC5947 and TLC59711 PWM LED Driver Breakouts](https://learn.adafruit.com/tlc5947-tlc59711-pwm-led-driver-breakout/downloads-and-links)**
>
> Adafruit's 12 and 24 channel PWM drivers are the perfect choice for driving lots of LEDs. Using just 3 SPI pins, you can drive 12 or 24 LEDs with one of these boards. And you can chain together as many as you need to control an almost unlimited...

Thanks.. Tom.. 😃 👍 ☕ 🇦🇺

---

<div class="post-metadata">

**Author:** ![dworza](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/dworza/32/906426_2.png) [@dworza](https://forum.arduino.cc/u/dworza)\
**Post date:** [January 4, 2023, 2:10am UTC](https://forum.arduino.cc/t/basic-set-up-for-tpic6b595-shift-register-with-pwm/1072907/4 "2023-01-04T02:10:44Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![LarryD](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/larryd/32/215550_2.png) [@LarryD](https://forum.arduino.cc/u/LarryD)\
**Post date:** [January 4, 2023, 2:16am UTC](https://forum.arduino.cc/t/basic-set-up-for-tpic6b595-shift-register-with-pwm/1072907/5 "2023-01-04T02:16:51Z")

</div>

> [@dworza](#):
>
> `TPIC6B595`

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/9/d/7/9d74c399657f8bd99f1b34ceb08eae79e49ef2bd.jpeg)

Connect the G’ pin to an Arduino PWM PIN.

---

<div class="post-metadata">

**Author:** ![dworza](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/dworza/32/906426_2.png) [@dworza](https://forum.arduino.cc/u/dworza)\
**Post date:** [January 4, 2023, 2:17am UTC](https://forum.arduino.cc/t/basic-set-up-for-tpic6b595-shift-register-with-pwm/1072907/6 "2023-01-04T02:17:23Z")

</div>

> [@TomGeorge](#):
>
> How do you aim to PWM through a shift register?

My idea was to analogWrite to a G pin. I saw a similar example for 74HC595 and thought that it should also work here.

> [@TomGeorge](#):
>
> This would be better and easier to code.

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.

---

<div class="post-metadata">

**Author:** ![LarryD](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/larryd/32/215550_2.png) [@LarryD](https://forum.arduino.cc/u/LarryD)\
**Post date:** [January 4, 2023, 2:19am UTC](https://forum.arduino.cc/t/basic-set-up-for-tpic6b595-shift-register-with-pwm/1072907/7 "2023-01-04T02:19:49Z")

</div>

> [@dworza](#):
>
> My idea was to analogWrite to a G pin.

Yes, connect the G’ pin to an Arduino PWM pin.

---

<div class="post-metadata">

**Author:** ![dworza](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/dworza/32/906426_2.png) [@dworza](https://forum.arduino.cc/u/dworza)\
**Post date:** [January 4, 2023, 2:24am UTC](https://forum.arduino.cc/t/basic-set-up-for-tpic6b595-shift-register-with-pwm/1072907/8 "2023-01-04T02:24:26Z")

</div>

> [@LarryD](#):
>
> Arduino PWM PIN.

I connected G to pin 11 on Arduino, changed it in the code

```arduino
const int GPin = 11; 

```

But the LEDs won't light up (unless I'd connect directly Vcc with 5v on Arudino). Is there a problem with the code maybe?

---

<div class="post-metadata">

**Author:** ![LarryD](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/larryd/32/215550_2.png) [@LarryD](https://forum.arduino.cc/u/LarryD)\
**Post date:** [January 4, 2023, 2:28am UTC](https://forum.arduino.cc/t/basic-set-up-for-tpic6b595-shift-register-with-pwm/1072907/9 "2023-01-04T02:28:53Z")

</div>

The chips Vcc pin needs to be connected to the Arduino 5v pin.

There should also be a decoupling capacitor on this pin to GND (0V).  
100nF ceramic

---

<div class="post-metadata">

**Author:** ![dworza](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/dworza/32/906426_2.png) [@dworza](https://forum.arduino.cc/u/dworza)\
**Post date:** [January 4, 2023, 2:33am UTC](https://forum.arduino.cc/t/basic-set-up-for-tpic6b595-shift-register-with-pwm/1072907/10 "2023-01-04T02:33:11Z")

</div>

> [@LarryD](#):
>
> 100nF

It works! Thanks, @LarryD , you made my day! I honestly didn't know that not all the pins on Arduino can be used for PWM.

---

<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:** [January 4, 2023, 3:54am UTC](https://forum.arduino.cc/t/basic-set-up-for-tpic6b595-shift-register-with-pwm/1072907/11 "2023-01-04T03:54:53Z")

</div>

Hi, @dworza

> [@dworza](#):
>
> My idea was to analogWrite to a G pin. I saw a similar example for 74HC595 and thought that it should also work here.

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.

Tom.. 😃 👍 ☕ 🇦🇺

---

<div class="post-metadata">

**Author:** ![dougp](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/dougp/32/238908_2.png) [@dougp](https://forum.arduino.cc/u/dougp)\
**Post date:** [January 9, 2023, 3:13pm UTC](https://forum.arduino.cc/t/basic-set-up-for-tpic6b595-shift-register-with-pwm/1072907/12 "2023-01-09T15:13:53Z")

</div>

> [@dworza](#):
>
> I honestly didn't know that not all the pins on Arduino can be used for PWM.

The pins with a tilde (3, 5, 6, 9, 10, 11) are hardware-capable PWM pins. See post #3:

> [@Something as 8LED snake](https://forum.arduino.cc/t/something-as-8led-snake/1039552):
>
> I simply try to create a short LED wave that circularly switch 3LED´s with diferent intensity. Can somebody explain why this routine don´t work as I want? [run light.ino - Wokwi Arduino and ESP32 Simulator](https://wokwi.com/projects/344881630386586196)

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [July 8, 2023, 3:14pm UTC](https://forum.arduino.cc/t/basic-set-up-for-tpic6b595-shift-register-with-pwm/1072907/13 "2023-07-08T15:14:16Z")

</div>

Closed on July 8, 2023, 3:14pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
