Arduino wirth 74165 Hookup for LEDs

As mentioned in Headline

Here is the code below to operate LEDs at some of the outputs of same Arduino UNO on which A
74165 is applied to operate multiple outs with only 2 inputs

/*
  74HC165 Shift Register Demonstration 1
  74hc165-demo.ino
  Read from 8 switches and display values on serial monitor

  DroneBot Workshop 2020
  https://dronebotworkshop.com
*/

// Define Connections to 74HC165

// PL pin 1
int load = 7;
// CE pin 15
int clockEnablePin = 4;
// Q7 pin 7
int dataIn = 5;
// CP pin 2
int clockIn = 6;

int led1 = 8;
int led2 = 9;
int led3 = 10;
int led4 = 11;

void setup()
{

  // Setup Serial Monitor
  Serial.begin(9600);

  // Setup 74HC165 connections
  pinMode(load, OUTPUT);
  pinMode(clockEnablePin, OUTPUT);
  pinMode(clockIn, OUTPUT);
  pinMode(dataIn, INPUT);

  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  digitalWrite(led1,1);
  delay(250);
  digitalWrite(led2,1);
  delay(250);
  digitalWrite(led1,0);
  delay(250);
  digitalWrite(led2,0);

}

void loop()
{

  // Write pulse to load pin
  digitalWrite(load, LOW);
  delayMicroseconds(5);
  digitalWrite(load, HIGH);
  delayMicroseconds(5);

  // Get data from 74HC165
  digitalWrite(clockIn, HIGH);
  digitalWrite(clockEnablePin, LOW);
  byte incoming = shiftIn(dataIn, clockIn, LSBFIRST);
  digitalWrite(clockEnablePin, HIGH);

  // Print to serial monitor
  Serial.print("Pin States:\r\n");
  Serial.println(incoming, BIN);
  delay(1000);

  if(incoming=10111111)
  {
    digitalWrite(led1,1);
  }
  else
  {
  digitalWrite(led1,0);
  }
}

A sample figure on which I am working on

I am not able to operate LEDs with all these arrangements

I want to use push button to glow LEDs On and releasing push buttons ll set it OFF

The 165 is an input shift register (parallel to serial - good for button - see your drawing).
The 595 is an output shift register (serial to parallel - good for LEDs). Example.

Actually I want to operate it like this only

From a single input I want to implant multiple inputs so as to operate maximum number of outputs

I can go for further any board but trying to study it an Arduino UNO
Only for experiment purpose !!

First you want LEDs then you change to buttons. We all know what is next.

Firstly the theory of simple push button and LED only

Rest I ll do

Just the triggering script and that's it !!!

No extra thing

Just random selection of each LED depending on each allotted push button and done

simple code for that part only

I tried with this

if(incoming=10111111)
  {
    digitalWrite(led1,1);
  }
  else
  {
  digitalWrite(led1,0);
  }

But it is totally out of the script like thing

So please let me know the actual one !!

No, you did not. It is incomplete.

Hahhaha. 80.

DON'T HAVE ANY SINGLE IDEA i JUST APPLIED IT ON BASIS OF PREVIOUS STUDY

IT IS INCOMPLETE OR NOT OR IT IS RIGHT OR WRONG , NO IDEA

JUST NEED TO HAVE THE PROPER SCRIPT OF HAVING A PUSH BUTTON AS A SWITCH FOR GLOWING LED ON AND OFF !!!

THAT'S IT !!!

You do have an idea. You showed a simulation. Try it.

It IS incomplete, but now you have the idea.

You have all the information on exactly what you must do here.

/*
  74HC165 Shift Register Demonstration 1
  74hc165-demo.ino
  Read from 8 switches and display values on serial monitor

  DroneBot Workshop 2020
  https://dronebotworkshop.com
*/

// Define Connections to 74HC165

// PL pin 1
int load = 7;
// CE pin 15
int clockEnablePin = 4;
// Q7 pin 7
int dataIn = 5;
// CP pin 2
int clockIn = 6;

int led1 = 8;
int led2 = 9;
int led3 = 10;
int led4 = 11;

void setup()
{

  // Setup Serial Monitor
  Serial.begin(9600);

  // Setup 74HC165 connections
  pinMode(load, OUTPUT);
  pinMode(clockEnablePin, OUTPUT);
  pinMode(clockIn, OUTPUT);
  pinMode(dataIn, INPUT);

  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  digitalWrite(led1,1);
  delay(250);
  digitalWrite(led2,1);
  delay(250);
  digitalWrite(led1,0);
  delay(250);
  digitalWrite(led2,0);

}

void loop()
{

  // Write pulse to load pin
  digitalWrite(load, LOW);
  delayMicroseconds(5);
  digitalWrite(load, HIGH);
  delayMicroseconds(5);

  // Get data from 74HC165
  digitalWrite(clockIn, HIGH);
  digitalWrite(clockEnablePin, LOW);
  byte incoming = shiftIn(dataIn, clockIn, LSBFIRST);
  digitalWrite(clockEnablePin, HIGH);

  // Print to serial monitor
  Serial.print("Pin States:\r\n");
  Serial.println(incoming, BIN);
  delay(1000);

  if(incoming=10111111)
  {
    digitalWrite(led1,1);
  }
  else
  {
  digitalWrite(led1,0);
  }
}

What is missing in this code ??

Please let me know

I tried it all the way but not able to get the issue !!!

0b….

Your wiring.

Should be:

if(incoming == 0b10111111)

B

and

if ("==") not if ("=")

Already mentioned in post#1

It is exactly the same one !!!

Ya it is working now

One thing is here

When we press and hold the push button the LED starts flashing with high speed

How to make a constant glow on HOLD

and then OFF on release ?

The title of your topic says "LED" - your drawing shows no LEDs.

Post. The. Code.

Once you've been on these fora for awhile, you will learn that we can't fix code we can't see.

Oh, wait...

a7

Just connected simply 2 LEDs under observation at pin 8 and pin 9
by means of a 100 ohms resistors and ground
No special arrangements !!!

Post your new drawing, here.

O yes yes I just forgot to change it actually
Previously I did with '==' only and then replaced it with '=' to check if I am doing the way wrong

Then not after getting any result any of the way, I pasted it as it is without making corrections
:joy:

Well this "0b" is working fine but on PRESS and HOLD the push button the LED starts flashing with a high speed

I want to making it glow constantly on PRESS and HOLD
and set the LED OFF on release

Whats the trick here to do so ?