Having trouble with 74HC595 and Uno Just picked up a couple of 74HC595 shift registers to use for my Arduino Uno, and I'm having trouble getting it working 100% of the time. My code is to get a value from the Serial monitor and shift it into the register. The issue is that bits 4 and 5 are always on no matter what I put into the monitor, but when I clock a 0 into the register during setup(), it works as expected, i.e. all LEDs go off

Here is the code:

int dataPin = 2;
int latchPin = 3;
int clockPin = 4;


void setup() {
    Serial.begin(9600);
    pinMode(dataPin, OUTPUT);      
    pinMode(latchPin, OUTPUT);
    pinMode(clockPin, OUTPUT);

    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, 0);
    digitalWrite(latchPin, HIGH);
}

void loop() {
    if(Serial.available()) {
        digitalWrite(latchPin, LOW);
        shiftOut(dataPin, clockPin, MSBFIRST, Serial.read());
        digitalWrite(latchPin, HIGH);
    }
}


Is it the code that is wrong? Do i have a busted shift register? Or something else?
Thanks
Serial.read() is going to give you ASCII codes.  So when you send 1 from the serial monitor the Arduino receives 49.  Note that the ASCII code for a digit is the same as the digit plus 48, so that sets bits 4 and 5 high.  

You can use Serial.read() - '0' to get the actual number from the ascii code.