2pcs 74HC595 with 16ch led + potentiometer.

I mean only LDR with resistor part as ADC.

About PWM it won't be problem when I'm using 2x 74hc595?

I will check all about monday.

Only I have question about resistance? Which I need for resistor and photoresistor?

Which I need for resistor and photoresistor?

To get best results measure the resistance of the LDR in the medium light levels you want to use and make the resistor the closest standard value to that. This gives you the best range.

Making use of the internal pull up resistor might do the job.

Connect the LDR between A0 and ground, and run this sketch.
Write down the numbers you see on the serial monitor when the room is light/dark.
You can use (map) these numbers to PWM values in the final sketch.
Leo..

const byte LDRpin = A0;

void setup() {
  Serial.begin(9600);
  pinMode(LDRpin, INPUT_PULLUP);
}

void loop() {
  Serial.println(analogRead(LDRpin));
  delay(250);
}

Thanks for reply.

30-40 when it's sunny

120-130 when it's dark

I don't know the resistance of LDR - I have bought it with kit for arduino. Finally I will buy about 10pcs new LDR but I don't know which model - I have about 5-7 others LDR with different resistances.

Look at the "map" examples in help>reference>map of the IDE.

There is explained how you can map/convert the LDR value of 30-130 to PWM dim values of e.g. 0-250.
Leo..

const byte LDRpin = A0;

void setup() {
  Serial.begin(9600);
  pinMode(LDRpin, INPUT_PULLUP);
}

void loop() {
  Serial.println(analogRead(LDRpin));
  delay(250);

  int val = analogRead(LDRpin);
  val = map(val, 0, 40, 0, 64);
  val = map(val, 40,80, 65, 128);
  val = map(val, 80,120, 128, 192);
  val = map(val, 120, 200,192,255);
  analogWrite(10, val);
}

Untested, and you still need to add the main code (see comments).
Leo..

const byte LDRpin = A1; // LDR connected to pin A1 and ground (A0 is used for the pot)
const byte PWMpin = 10; // connected to the two OE pins
int lightValue = 30; // change/experiment with this value
int darkValue = 130; // change/experiment with this value
int LDRvalue;
byte PWMvalue;
// other declarations go here

void setup() {
  Serial.begin(9600); // only needed for debugging
  pinMode(LDRpin, INPUT_PULLUP); // enables the internal pull up resistor
  pinMode(PWMpin, OUTPUT); // make the pin an output
  // other void setup() code goes here
}

void loop() {
  LDRvalue = analogRead(LDRpin);
  Serial.print("LDR value is: ");
  Serial.println(LDRvalue);
  LDRvalue = constrain(LDRvalue, lightValue, darkValue);
  PWMvalue = map(LDRvalue, lightValue, darkValue, 0, 250);
  Serial.print("PWM value is: ");
  Serial.println(PWMvalue);
  analogWrite(PWMpin, PWMvalue); // write to the OE pins
  // other void loop() code goes here

  delay(1000); // remove this line after testing
}
const byte LDRpin = A2; // LDR connected to pin A1 and ground (A0 is used for the pot)
const byte PWMpin = 10; // connected to the two OE pins
int lightValue = 30; // change/experiment with this value
int darkValue = 130; // change/experiment with this value
int LDRvalue;
byte PWMvalue;
int latchPin = 4;
int clockPin = 5;
int dataPin = 3;
int potPin = 0;
int potValue = 0;
int shiftValue = 0;

#define Out1Pin 1  //out1 230vac
#define Out2Pin 2 //out2 230vac
#define Out3Pin 0 //out3 5vdc
#define MutePin A2 //mute
#define VolUpPin 10 //up
#define VolDownPin A1 //down
#define CH1Pin A3 //ch1
#define CH2Pin A4 //ch2
#define CH3Pin A5 //ch3
#include <IRremote.h>
#define irPin 8  // pin dla TSOP
IRrecv irrecv(irPin);
decode_results results;





void setup() {
  //Serial.begin(9600); // only needed for debugging

  
     irrecv.enableIRIn();
     
   pinMode(Out1Pin, OUTPUT);
   pinMode(Out2Pin, OUTPUT);
   pinMode(Out3Pin, OUTPUT);
   pinMode(MutePin, OUTPUT);
   pinMode(VolUpPin, OUTPUT);
   pinMode(VolDownPin, OUTPUT);
   pinMode(CH1Pin, OUTPUT);
   pinMode(CH2Pin, OUTPUT);
   pinMode(CH3Pin, OUTPUT);
   pinMode(LDRpin, INPUT_PULLUP); // enables the internal pull up resistor
   pinMode(PWMpin, OUTPUT); // make the pin an output




   digitalWrite(0, LOW);
   digitalWrite(1, LOW);
   digitalWrite(2, LOW);
   digitalWrite(A2, HIGH);
   digitalWrite(10, LOW);
   digitalWrite(A1, LOW);
   digitalWrite(A3, HIGH);
   digitalWrite(A4, LOW);
   digitalWrite(A5, LOW);

   pinMode(latchPin, OUTPUT);
   pinMode(dataPin, OUTPUT);  
   pinMode(clockPin, OUTPUT);

}

void loop() {
  LDRvalue = analogRead(LDRpin);
  Serial.print("LDR value is: ");
  Serial.println(LDRvalue);
  LDRvalue = constrain(LDRvalue, lightValue , darkValue);
  PWMvalue = map(LDRvalue, lightValue, darkValue, 0, 250);
  Serial.print("PWM value is: ");
  Serial.println(PWMvalue);
  analogWrite(PWMpin, PWMvalue); // write to the OE pins

if (irrecv.decode(&results))
   {
       switch (results.value)
       {
         case 0x801:  // kod klawisza 1
            digitalWrite(Out1Pin, LOW);
            break;
            
         case 0x1:  // kod klawisza 1
            digitalWrite(Out1Pin, HIGH);
            break;
            
         case 0x802:  // kod klawisza 2
            digitalWrite(Out2Pin, LOW);
            break;
            
         case 0x2:  // kod klawisza 2
            digitalWrite(Out2Pin, HIGH);
            break;
            
         case 0x803:  // kod klawisza 3
            digitalWrite(Out3Pin, LOW);
            break;
            
         case 0x3:  // kod klawisza 3
            digitalWrite(Out3Pin, HIGH);
            break;
            
         case 0x80D:  // kod klawisza 4
            digitalWrite(MutePin, LOW);
            break;
            
         case 0xD:  // kod klawisza 4
            digitalWrite(MutePin, HIGH);
            break;

         case 0x807:  // kod klawisza 7 CH1
            digitalWrite(CH2Pin, LOW);
            digitalWrite(CH3Pin, LOW);
            digitalWrite(CH1Pin, HIGH);
            break;
            
         case 0x7:  // kod klawisza 7 CH1
            digitalWrite(CH2Pin, LOW);
            digitalWrite(CH3Pin, LOW);
            digitalWrite(CH1Pin, HIGH);
            break;      
                  
          case 0x808:  // kod klawisza 8 CH2
            digitalWrite(CH1Pin, LOW);
            digitalWrite(CH3Pin, LOW);
            digitalWrite(CH2Pin, HIGH);
            break;
            
         case 0x8:  // kod klawisza 8 CH2
            digitalWrite(CH1Pin, LOW);
            digitalWrite(CH3Pin, LOW);
            digitalWrite(CH2Pin, HIGH);
            break;  
                     
          case 0x809:  // kod klawisza 9 CH3
            digitalWrite(CH1Pin, LOW);
            digitalWrite(CH2Pin, LOW);
            digitalWrite(CH3Pin, HIGH);
            break;
            
         case 0x9:  // kod klawisza 9 CH3
            digitalWrite(CH1Pin, LOW);
            digitalWrite(CH2Pin, LOW);
            digitalWrite(CH3Pin, HIGH);
            break;  

            
         case 0x11:  // kod klawisza 5
            digitalWrite(VolUpPin, LOW);
            delay(250);
            digitalWrite(VolDownPin, LOW);
            break;
            
         case 0x811:  // kod klawisza 5
            digitalWrite(VolUpPin, HIGH);
            delay(250);
            digitalWrite(VolUpPin, LOW);
            break;
            
         case 0x10:  // kod klawisza 6
            digitalWrite(VolDownPin, LOW);
            delay(250);
            digitalWrite(VolUpPin, LOW);
            break;
            
         case 0x810:  // kod klawisza 6
            digitalWrite(VolDownPin, HIGH);
            delay(250);
            digitalWrite(VolDownPin, LOW);
            break;
            
         case 0x80C:  // kod klawisza OFF
            digitalWrite(Out1Pin, HIGH);
            digitalWrite(Out2Pin, HIGH);
            digitalWrite(Out3Pin, HIGH);
            //digitalWrite(MutePin, HIGH);
            break;
            
         case 0xC:  // kod klawisza OFF
            digitalWrite(Out1Pin, LOW);
            digitalWrite(Out2Pin, LOW);
            digitalWrite(Out3Pin, LOW);
            //digitalWrite(MutePin, LOW);
            break;


         }
   irrecv.resume();
   }

// read pot &  update outputs to 2 daisy chained shift registers
potValue = analogRead(A0);

if ( potValue >=0 && potValue <=20)
{
shiftValue = 0b1111111111111111;
}

if ( potValue >=20 && potValue <=63)
{
shiftValue = 0b0111111111111111;
}

if ( potValue >=63 && potValue <=126)
{
shiftValue = 0b0011111111111111;
}

if ( potValue >=126 && potValue <=189)
{
shiftValue = 0b0001111111111111;
}

if ( potValue >=189 && potValue <=252)
{
shiftValue = 0b0000111111111111;
}

if ( potValue >=252 && potValue <=315)
{
shiftValue = 0b0000011111111111;
}

if ( potValue >=315 && potValue <=378)
{
shiftValue = 0b0000001111111111;
}

if ( potValue >=378 && potValue <=441)
{
shiftValue = 0b0000000111111111;
}

if ( potValue >=441 && potValue <=504)
{
shiftValue = 0b0000000111111111;
}

if ( potValue >=504 && potValue <=567)
{
shiftValue = 0b0000000011111111;
}

if ( potValue >=567 && potValue <=630)
{
shiftValue = 0b0000000001111111;
}

if ( potValue >=630 && potValue <=693)
{
shiftValue = 0b0000000000111111;
}

if ( potValue >=693 && potValue <=756)
{
shiftValue = 0b0000000000011111;
}

if ( potValue >=756 && potValue <=819)
{
shiftValue = 0b0000000000001111;
}

if ( potValue >=819 && potValue <=882)
{
shiftValue = 0b0000000000000111;
}

if ( potValue >=882 && potValue <=945)
{
shiftValue = 0b0000000000000011;
}

if ( potValue >=945 && potValue <=1010)
{
shiftValue = 0b0000000000000001;
}

if ( potValue >=1010 && potValue <=1023)
{
shiftValue = 0b0000000000000000;
}



digitalWrite (latchPin, LOW);
shiftOut (dataPin, clockPin, MSBFIRST, highByte (shiftValue)); // upper 8 bits
shiftOut (dataPin, clockPin, MSBFIRST, lowByte (shiftValue)); // lower 8  bits
digitalWrite (latchPin, HIGH);
  delay(1000); // remove this line after testing
}

This code works, I delete delay at last line. Only what's wrong -leds are blinking xxxx per seconds. It is possible to fix it?

gavron04:
It is possible to fix it?

Not if I know why it's doing that.
Are you sure the LDR can't "see" the light of the LEDs.
Does the room have natural or artificial light.
Are the values on the serial monitor also "pumping"
(you might have to put that delay in, to slow down printing).
Leo..

Yes, I'm sure.

With led bulb or with natural light the same.

On serial monitor:

LDR value is: 98
PWM value is: 109
LDR value is: 99
PWM value is: 111
LDR value is: 100
PWM value is: 113
LDR value is: 101
PWM value is: 115
LDR value is: 101
PWM value is: 115
LDR value is: 101
PWM value is: 115
LDR value is: 99
PWM value is: 111
LDR value is: 96
PWM value is: 104
LDR value is: 99
PWM value is: 111
LDR value is: 99
PWM value is: 111
LDR value is: 99
PWM value is: 111
LDR value is: 101
PWM value is: 115
LDR value is: 100
PWM value is: 113
LDR value is: 99
PWM value is: 111
LDR value is: 98
PWM value is: 109
LDR value is: 98
PWM value is: 109
LDR value is: 99
PWM value is: 111
LDR value is: 100
PWM value is: 113
LDR value is: 105
PWM value is: 125
LDR value is: 100
PWM value is: 113
LDR value is: 96
PWM value is: 104
LDR value is: 99
PWM value is: 111
LDR value is: 98
PWM value is: 109
LDR value is: 97
PWM value is: 106
LDR value is: 99
PWM value is: 111
LDR value is: 100
PWM value is: 113
LDR value is: 100
PWM value is: 113
LDR value is: 100
PWM value is: 113
LDR value is: 99
PWM value is: 111
LDR value is: 98
PWM value is: 109
LDR value is: 97
PWM value is: 106
LDR value is: 107
PWM value is: 129
LDR value is: 100
PWM value is: 113
LDR value is: 96
PWM value is: 104
LDR value is: 101
PWM value is: 115
LDR value is: 99
PWM value is: 111
LDR value is: 98
PWM value is: 109
LDR value is: 98
PWM value is: 109
LDR value is: 98
PWM value is: 109
LDR value is: 98
PWM value is: 109
LDR value is: 100
PWM value is: 113
LDR value is: 100
PWM value is: 113
LDR value is: 100
PWM value is: 113
LDR value is: 99
PWM value is: 111
LDR value is: 99
PWM value is: 111
LDR value is: 97
PWM value is: 106
LDR value is: 96
PWM value is: 104
LDR value is: 100
PWM value is: 113
LDR value is: 100
PWM value is: 113
LDR value is: 99
PWM value is: 111
LDR value is: 100
PWM value is: 113
LDR value is: 98
PWM value is: 109
LDR value is: 98
PWM value is: 109
LDR value is: 98
PWM value is: 109
LDR value is: 98
PWM value is: 109
LDR value is: 100
PWM value is: 113
LDR value is: 100
PWM value is: 113
LDR value is: 101
PWM value is: 115
LDR value is: 99
PWM value is: 111
LDR value is: 88
PWM value is: 86
LDR value is: 99
PWM value is: 111
LDR value is: 98
PWM value is: 109
LDR value is: 97
PWM value is: 106
LDR value is: 100
PWM value is: 113
LDR value is: 100
PWM value is: 113
LDR value is: 99
PWM value is: 111
LDR value is: 99
PWM value is: 111
LDR value is: 98
PWM value is: 109
LDR value is: 97
PWM value is: 106
LDR value is: 98
PWM value is: 109
LDR value is: 99
PWM value is: 111
LDR value is: 100
PWM value is: 113
LDR value is: 100
PWM value is: 113
LDR value is: 100
PWM value is: 113
LDR value is: 98
PWM value is: 109
LDR value is: 96
PWM value is: 104
LDR value is: 98
PWM value is: 109
LDR value is: 98
PWM value is: 109
LDR value is: 98
PWM value is: 109
LDR value is: 100
PWM value is: 113
LDR value is: 100
PWM value is: 113
LDR value is: 99
PWM value is: 111
LDR value is: 98
PWM value is: 109
LDR value is: 97
PWM value is: 106
LDR value is: 98
PWM value is: 109
LDR value is: 99
PWM value is: 111
LDR value is: 100
PWM value is: 113
LDR value is: 100
PWM value is: 113
LDR value is: 99
PWM value is: 111
LDR value is: 99
PWM value is: 111
LDR value is: 98
PWM value is: 109
LDR value is: 96
PWM value is: 104
LDR value is: 99
PWM value is: 111
LDR value is: 99
PWM value is: 111
LDR value is: 98
PWM value is: 109
LDR value is: 100
PWM value is: 113
LDR value is: 99
PWM value is: 111
LDR value is: 97
PWM value is: 106
LDR value is: 97
PWM value is: 106
LDR value is: 97
PWM value is: 106
LDR value is: 98
PWM value is: 109
LDR value is: 100
PWM value is: 113
LDR value is: 100
PWM value is: 113
LDR value is: 100
PWM value is: 113
LDR value is: 99
PWM value is: 111
LDR value is: 99
PWM value is: 111
LDR value is: 97
PWM value is: 106
LDR value is: 98
PWM value is: 109
LDR value is: 100
PWM value is: 113
LDR value is: 100
PWM value is: 113
LDR value is: 98
PWM value is: 109
LDR value is: 99
PWM value is: 111
LDR value is: 98
PWM value is: 109
LDR value is: 97
PWM value is: 106
LDR value is: 97
PWM value is: 106
LDR value is: 98
PWM value is: 109
LDR value is: 99
PWM value is: 111
LDR value is: 100
PWM value is: 113
LDR value is: 100
PWM value is: 113
LDR value is: 99
PWM value is: 111
LDR value is: 98
PWM value is: 109
LDR value is: 107
PWM value is: 129
LDR value is: 97
PWM value is: 106
LDR value is: 96
PWM value is: 104
LDR value is: 100
PWM value is: 113
LDR value is: 100
PWM value is: 113
LDR value is: 98
PWM value is: 109
LDR value is: 98
PWM value is: 109
LDR value is: 140
PWM value is: 204
LDR value is: 140
PWM value is: 204
LDR value is: 141
PWM value is: 206
LDR value is: 132
PWM value is: 186
LDR value is: 139
PWM value is: 202
LDR value is: 137
PWM value is: 197
LDR value is: 137
PWM value is: 197
LDR value is: 137
PWM value is: 197
LDR value is: 139
PWM value is: 202
LDR value is: 141
PWM value is: 206
LDR value is: 140
PWM value is: 204
LDR value is: 140
PWM value is: 204
LDR value is: 139
PWM value is: 202
LDR value is: 137
PWM value is: 197
LDR value is: 137
PWM value is: 197
LDR value is: 137
PWM value is: 197
LDR value is: 146
PWM value is: 218

Second question. I have 2x 74HC595. It has max. 70mA, per channel max. 20mA. I have found TPIC6C595. It has max. 250mA. Per channel max. 100mA. Now I must adjust about 8mA per LED. When I would have TPIC6SC595 I will have without problem 20mA per LED. Software is the same as for 74HC595 or not?

It seems you have to use smoothing code to stabilise those PWM writes.

A TPIC can only switch to ground.
The LEDs need to go between outputs and 5volt (all anodes to 5volt).

Code stays the same.
Leo..

It is possible to create compartments / within range like: when LDR value 140-145 then PWM is still 204?

TPIC pin G is the same as OE in 74HC595?

It is possible to create compartments / within range like: when LDR value 140-145 then PWM is still 204?

Yes use a compound if like this:-

if(value >=140 && value <=145) { // do stuff

Thanks. Tomorrow I will test.

So if LDR works without additionally resistor can I make PCB with directly connected LDR to analog input pin and gnd?

This LDR will be ok? GM3526 WODEYIJIA - Photoresistor | 50mW; 10÷20kΩ; 540nm; THT; 100VDC; Dim: 3.3x3mm | TME - Electronic components (WFS) (I don't know which LDR I have now)

Well according to the data sheet at 10 Lux using the internal resistor you will get a reading between 128 and 256.

I will buy 5 different types of LDR and I will test which is the best.

I have question about my code. It is possible to add second 74HC595 which will drive ULN2003 (on other pins on atmega)

if (irrecv.decode(&results))
   {
       switch (results.value)
       {
         case 0x801:  // kod klawisza 1
            digitalWrite(Out1Pin, LOW);
            break;
            
         case 0x1:  // kod klawisza 1
            digitalWrite(Out1Pin, HIGH);
            break;
            
         case 0x802:  // kod klawisza 2
            digitalWrite(Out2Pin, LOW);
            break;
            
         case 0x2:  // kod klawisza 2
            digitalWrite(Out2Pin, HIGH);
            break;
            
         case 0x803:  // kod klawisza 3
            digitalWrite(Out3Pin, LOW);
            break;
            
         case 0x3:  // kod klawisza 3
            digitalWrite(Out3Pin, HIGH);
            break;
            
         case 0x80D:  // kod klawisza 4
            digitalWrite(MutePin, LOW);
            break;
            
         case 0xD:  // kod klawisza 4
            digitalWrite(MutePin, HIGH);
            break;

         case 0x807:  // kod klawisza 7 CH1
            digitalWrite(CH2Pin, LOW);
            digitalWrite(CH3Pin, LOW);
            digitalWrite(CH1Pin, HIGH);
            break;
            
         case 0x7:  // kod klawisza 7 CH1
            digitalWrite(CH2Pin, LOW);
            digitalWrite(CH3Pin, LOW);
            digitalWrite(CH1Pin, HIGH);
            break;      
                  
          case 0x808:  // kod klawisza 8 CH2
            digitalWrite(CH1Pin, LOW);
            digitalWrite(CH3Pin, LOW);
            digitalWrite(CH2Pin, HIGH);
            break;
            
         case 0x8:  // kod klawisza 8 CH2
            digitalWrite(CH1Pin, LOW);
            digitalWrite(CH3Pin, LOW);
            digitalWrite(CH2Pin, HIGH);
            break;  
                     
          case 0x809:  // kod klawisza 9 CH3
            digitalWrite(CH1Pin, LOW);
            digitalWrite(CH2Pin, LOW);
            digitalWrite(CH3Pin, HIGH);
            break;
            
         case 0x9:  // kod klawisza 9 CH3
            digitalWrite(CH1Pin, LOW);
            digitalWrite(CH2Pin, LOW);
            digitalWrite(CH3Pin, HIGH);
            break;

I need more free pins and it is only way to disconnected directly wiring atmega<>uln2003 and add between atmega and uln one 74HC595.

I have problem. How can I leave alone some pins without change status (low,high)?

I have 3 outputs on/off on relay.

If I pressed 1
shiftValue = 0b0111111111111111;

If I pressed 2
shiftValue = 0b1011111111111111;

If I pressed 3
shiftValue = 0b1101111111111111;

So after pressed 1 - I turn on 1, but others pin are off.

About LDR and within range.

const byte LDRpin = A2; // LDR connected to pin A1 and ground (A0 is used for the pot)
const byte PWMpin = 10; // connected to the two OE pins
int lightValue = 50; // change/experiment with this value
int darkValue = 160; // change/experiment with this value
int LDRvalue;
byte PWMvalue;


void setup() 

{

  Serial.begin(9600); // only needed for debugging
  pinMode(LDRpin, INPUT_PULLUP); // enables the internal pull up resistor
  pinMode(PWMpin, OUTPUT); // make the pin an output

}


void loop() 

{
  LDRvalue = analogRead(LDRpin);
  Serial.print("LDR value is: ");
  Serial.println(LDRvalue);
  LDRvalue = constrain(LDRvalue, lightValue , darkValue);
  PWMvalue = map(LDRvalue, lightValue, darkValue, 0, 250);
  Serial.print("PWM value is: ");
  Serial.println(PWMvalue);
  analogWrite(PWMpin, PWMvalue); // write to the OE pins
}

I have searched in reference, but I can't find how to do this. constrain/min/max it isn't it.

I need to do this:

if(LDRvalue >=140 && value <=145) 
{ 
PWMvalue = map(LDRvalue, lightValue, darkValue, 0,250);
analogWrite(PWMpin, PWMvalue);
}

if(LDRvalue >=120 && value <=125) 
{ 
PWMvalue = map(LDRvalue, lightValue, darkValue, 0,250);
analogWrite(PWMpin, PWMvalue);
}

It is ok or not?

const byte LDRpin = A2; // LDR connected to pin A1 and ground (A0 is used for the pot)
const byte PWMpin = 10; // connected to the two OE pins
int lightValue = 50; // change/experiment with this value
int darkValue = 160; // change/experiment with this value
int LDRvalue;
byte PWMvalue;

int latchPin = 4;
int clockPin = 5;
int dataPin = 3;
int potPin = 0;
int potValue = 0;

int shiftValue = 0;
int shift1Value = 0;
int latch1Pin = A4;
int clock1Pin = A5;
int data1Pin =  A3;

//#define Out1Pin 1  //out1 230vac
//#define Out2Pin 2 //out2 230vac
//#define Out3Pin 0 //out3 5vdc
//#define MutePin A2 //mute
#define VolUpPin 10 //up
#define VolDownPin A1 //down
//#define CH1Pin A3 //ch1
//#define CH2Pin A4 //ch2
//#define CH3Pin A5 //ch3
#include <IRremote.h>
#define irPin 8  // pin dla TSOP
IRrecv irrecv(irPin);
decode_results results;





void setup() {
  Serial.begin(9600); // only needed for debugging

  
     irrecv.enableIRIn();
     
   //pinMode(Out1Pin, OUTPUT);
   //pinMode(Out2Pin, OUTPUT);
   //pinMode(Out3Pin, OUTPUT);
   //pinMode(MutePin, OUTPUT);
   pinMode(VolUpPin, OUTPUT);
   pinMode(VolDownPin, OUTPUT);
   //pinMode(CH1Pin, OUTPUT);
   //pinMode(CH2Pin, OUTPUT);
   //pinMode(CH3Pin, OUTPUT);
   pinMode(LDRpin, INPUT_PULLUP); // enables the internal pull up resistor
   pinMode(PWMpin, OUTPUT); // make the pin an output




   //digitalWrite(0, LOW);
   //digitalWrite(1, LOW);
   //digitalWrite(2, LOW);
   //digitalWrite(A2, HIGH);
   //digitalWrite(10, LOW);
   //igitalWrite(A1, LOW);
   //digitalWrite(A3, HIGH);
   //digitalWrite(A4, LOW);
   //digitalWrite(A5, LOW);

   pinMode(latchPin, OUTPUT);
   pinMode(dataPin, OUTPUT);  
   pinMode(clockPin, OUTPUT);
   pinMode(latch1Pin, OUTPUT);
   pinMode(data1Pin, OUTPUT);  
   pinMode(clock1Pin, OUTPUT);

}

void loop() {
  LDRvalue = analogRead(LDRpin);
  Serial.print("LDR value is: ");
  Serial.println(LDRvalue);
  LDRvalue = constrain(LDRvalue, lightValue , darkValue);
  PWMvalue = map(LDRvalue, lightValue, darkValue, 0, 250);
  Serial.print("PWM value is: ");
  Serial.println(PWMvalue);
  analogWrite(PWMpin, PWMvalue); // write to the OE pins

if (irrecv.decode(&results))
   {
       switch (results.value)
       {
         case 0x801:  // kod klawisza 1
            //digitalWrite(Out1Pin, LOW);
            shift1Value = 0b0000000000000001;
            break;
            
         case 0x1:  // kod klawisza 1
            //digitalWrite(Out1Pin, HIGH);
            shift1Value = 0b0000000000000001;
            break;
            
         case 0x802:  // kod klawisza 2
            //digitalWrite(Out2Pin, LOW);
            shift1Value = 0b0000000000000010;
            break;
            
         case 0x2:  // kod klawisza 2
            //digitalWrite(Out2Pin, HIGH);
            shift1Value = 0b0000000000000010;
            break;
            
         case 0x803:  // kod klawisza 3
            //digitalWrite(Out3Pin, LOW);
            shift1Value = 0b0000000000000100;
            break;
            
         case 0x3:  // kod klawisza 3
            //digitalWrite(Out3Pin, HIGH);
            shift1Value = 0b0000000000000100;
            break;
            
         case 0x80D:  // kod klawisza 4
            //digitalWrite(MutePin, LOW);
            shift1Value = 0b0000000000001000;
            break;
            
         case 0xD:  // kod klawisza 4
            //digitalWrite(MutePin, HIGH);
            shift1Value = 0b0000000000001000;
            break;

         case 0x807:  // kod klawisza 7 CH1
            //digitalWrite(CH2Pin, LOW);
            //digitalWrite(CH3Pin, LOW);
            //digitalWrite(CH1Pin, HIGH);
             shift1Value = 0b0000000000010000;
            break;
            
         case 0x7:  // kod klawisza 7 CH1
            //digitalWrite(CH2Pin, LOW);
            //digitalWrite(CH3Pin, LOW);
            //digitalWrite(CH1Pin, HIGH);
            shift1Value = 0b0000000000010000;
            break;      
                  
          case 0x808:  // kod klawisza 8 CH2
            //digitalWrite(CH1Pin, LOW);
            //digitalWrite(CH3Pin, LOW);
            //digitalWrite(CH2Pin, HIGH);
            shift1Value = 0b0000000000100000;
            break;
            
         case 0x8:  // kod klawisza 8 CH2
            //digitalWrite(CH1Pin, LOW);
            //digitalWrite(CH3Pin, LOW);
            //digitalWrite(CH2Pin, HIGH);
            shift1Value = 0b0000000000100000;
            break;  
                     
          case 0x809:  // kod klawisza 9 CH3
            //digitalWrite(CH1Pin, LOW);
            //digitalWrite(CH2Pin, LOW);
            //digitalWrite(CH3Pin, HIGH);
            shift1Value = 0b0000000001000000;
            break;
            
         case 0x9:  // kod klawisza 9 CH3
            //digitalWrite(CH1Pin, LOW);
            //digitalWrite(CH2Pin, LOW);
            //digitalWrite(CH3Pin, HIGH);
            shift1Value = 0b0000000001000000;
            break;  

            
         case 0x11:  // kod klawisza 5
            digitalWrite(VolUpPin, LOW);
            delay(250);
            digitalWrite(VolDownPin, LOW);
            break;
            
         case 0x811:  // kod klawisza 5
            digitalWrite(VolUpPin, HIGH);
            delay(250);
            digitalWrite(VolUpPin, LOW);
            break;
            
         case 0x10:  // kod klawisza 6
            digitalWrite(VolDownPin, LOW);
            delay(250);
            digitalWrite(VolUpPin, LOW);
            break;
            
         case 0x810:  // kod klawisza 6
            digitalWrite(VolDownPin, HIGH);
            delay(250);
            digitalWrite(VolDownPin, LOW);
            break;
            
         case 0x80C:  // kod klawisza OFF
            //digitalWrite(Out1Pin, HIGH);
            //digitalWrite(Out2Pin, HIGH);
            //digitalWrite(Out3Pin, HIGH);
            shift1Value = 0b0000000000000000;
            break;
            
         case 0xC:  // kod klawisza OFF
            //digitalWrite(Out1Pin, LOW);
            //digitalWrite(Out2Pin, LOW);
            //digitalWrite(Out3Pin, LOW);
            shift1Value = 0b1111111111111111;
            break;
digitalWrite (latch1Pin, LOW);
shiftOut (data1Pin, clock1Pin, MSBFIRST, highByte (shift1Value)); // upper 8 bits
shiftOut (data1Pin, clock1Pin, MSBFIRST, lowByte (shift1Value)); // lower 8  bits
digitalWrite (latch1Pin, HIGH);
  delay(100); // remove this line after testing

         }
   irrecv.resume();
   }


// read pot &  update outputs to 2 daisy chained shift registers
potValue = analogRead(A0);

if ( potValue >=0 && potValue <=20)
{
shiftValue = 0b1111111111111111;
}

if ( potValue >=20 && potValue <=63)
{
shiftValue = 0b0111111111111111;
}

if ( potValue >=63 && potValue <=126)
{
shiftValue = 0b0011111111111111;
}

if ( potValue >=126 && potValue <=189)
{
shiftValue = 0b0001111111111111;
}

if ( potValue >=189 && potValue <=252)
{
shiftValue = 0b0000111111111111;
}

if ( potValue >=252 && potValue <=315)
{
shiftValue = 0b0000011111111111;
}

if ( potValue >=315 && potValue <=378)
{
shiftValue = 0b0000001111111111;
}

if ( potValue >=378 && potValue <=441)
{
shiftValue = 0b0000000111111111;
}

if ( potValue >=441 && potValue <=504)
{
shiftValue = 0b0000000111111111;
}

if ( potValue >=504 && potValue <=567)
{
shiftValue = 0b0000000011111111;
}

if ( potValue >=567 && potValue <=630)
{
shiftValue = 0b0000000001111111;
}

if ( potValue >=630 && potValue <=693)
{
shiftValue = 0b0000000000111111;
}

if ( potValue >=693 && potValue <=756)
{
shiftValue = 0b0000000000011111;
}

if ( potValue >=756 && potValue <=819)
{
shiftValue = 0b0000000000001111;
}

if ( potValue >=819 && potValue <=882)
{
shiftValue = 0b0000000000000111;
}

if ( potValue >=882 && potValue <=945)
{
shiftValue = 0b0000000000000011;
}

if ( potValue >=945 && potValue <=1010)
{
shiftValue = 0b0000000000000001;
}

if ( potValue >=1010 && potValue <=1023)
{
shiftValue = 0b0000000000000000;
}



digitalWrite (latchPin, LOW);
shiftOut (dataPin, clockPin, MSBFIRST, highByte (shiftValue)); // upper 8 bits
shiftOut (dataPin, clockPin, MSBFIRST, lowByte (shiftValue)); // lower 8  bits
digitalWrite (latchPin, HIGH);
  delay(100); // remove this line after testing

}

I have now this code. But second 74HC595 with ULN isn't work properly. When I press 1,2,3,OFF nothing happen.