I have a 74HC595 Shift Register with a LED (and resistor) on each of the 8 output pins. I can light them all up I can light one up

How do I light two up? For example the one on pin 2 and the one on pin 7

I used this a my starting point. https://learn.adafruit.com/adafruit-arduino-lesson-5-the-serial-monitor?view=all

Is 74HC595 Shift Register the correct componet to use?

2 Answers 2


You don't mention if you are using and Arduino, but I will assume that is the case.

Using the shift register to light up LEDs is fairly straight forward.

You can use the ShiftOut() function to send out an 8bit binary value to the register. https://www.arduino.cc/en/Reference/ShiftOut

In summary however, if you want to light up the LEDs on the output pins 2 and 7 you would shift out b01000010 to the shift register. If you wanted pins 4, 5 and 7 to light up, you shift out b01011000. These assume the least significant bit is sent first.

Here's an example:

// set shift register output pins 2 and 7 to high
uint8_t data = 1<<2 | 1<<7; // use bit shifting

digitalWrite(latchPin, LOW); 
shiftOut(dataPin, clockPin, LSBFIRST, data); // send the data
digitalWrite(latchPin, HIGH); 
  • Cheers, that works a charm Mar 13, 2017 at 19:00

How do I light two up? For example the one on pin 2 and the one on pin 7

If the LEDs are active high, sending 0x82 lights up the two LEDs.

If they are active low, sending ~0x82 lights up the same LEDs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.