Arduino Nano, ICSP header and 595 Shift register I'm trying to control a 4-digit 7 segment display with an Arduino Nano, but I'm getting something wrong. I'm using the ICSP header to interface with a 74HC595 Shift Register which is then connected to the display. I've tested and retested the connections and everything seems to be alright, however the shift register doesn't have the desired output, and I notice it only shifs one single bit when I press the reset button on the arduino board.

74HC595   |    A. Nano
DS     &lt;-----&gt; MOSI (ICSP)
SH_CP  &lt;-----&gt; SCK (ICSP)
ST_CP  &lt;-----&gt; D6
MR     &lt;-----&gt; 5V (ICSP)
OE     &lt;-----&gt; GND (ICSP)
VDD    &lt;-----&gt; 5V (ICSP)
GND    &lt;-----&gt; GND (ICSP)


My code:

//pin connected to STCP
const int latchPin = 6;
//pin connected to SHCP
const int clockPin = 17;
//pin connected to DS (MOSI)
const int dataPin = 11;

byte val=0;

void setup() {
  // put your setup code here, to run once:
  //SPI pins are output
  pinMode(latchPin,OUTPUT);
  pinMode(clockPin,OUTPUT);
  pinMode(dataPin,OUTPUT);

  pinMode(3,OUTPUT);
  updateRegister(0);

}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(3,HIGH);  
  for (int i=0; i&lt;8; i++) {
    updateRegister();
    delay(500);
  }   

}

void updateRegister() {
  //pull latch low to write new bits to the register
  digitalWrite(latchPin,LOW);
  //shift out the data
  shiftOut(dataPin,clockPin,LSBFIRST,val);
  //pull latch pin high so that the leds light up
  digitalWrite(latchPin,HIGH);
}
It is extremely confusing to have a variable val and then use _val in your function but then:

  shiftOut(dataPin,clockPin,LSBFIRST,val);


As James pointed out, you are not sending the value passed to the function, to the shift register.

Also this is just going to give you a boolean:

 updateRegister(!i);


Why take "not i" there?



I suggest you use SPI and not muck around with shiftOut. I have a page about the 595 chip including example code. eg.

#include &lt;SPI.h&gt;

const byte LATCH = 10;

void setup ()
{
  SPI.begin ();
}  // end of setup

byte c;
void loop ()
{
  c++;
  digitalWrite (LATCH, LOW);
  SPI.transfer (c);
  digitalWrite (LATCH, HIGH);
  delay (20);
}  // end of loop