I am a beginner at electronics. I was trying to light up 8 leds using a 74hc595. I did all the cabling and programming but faced a very unexpected result. When I upload a high bit to the register, it outputs a low bit, and vice versa. So when I want to light up all 8 leds, they all get dark. If I try to to get them all dark, then they altogether light up. Here is my code for lighting them up one by one (This actually makes them all dark one by one):
int pData = 2;
int pShift = 3;
int pLatch = 4;
void setup()
{
pinMode(pData, OUTPUT);
pinMode(pShift, OUTPUT);
pinMode(pLatch, OUTPUT);
}
void loop()
{
digitalWrite(pLatch, LOW);
digitalWrite(pShift, LOW);
digitalWrite(pData, HIGH);
digitalWrite(pShift, HIGH);
digitalWrite(pLatch, HIGH);
delay(500);
}
I can of course move on with this reverse logic, uploading high when I need low, etc, but seriously, what is going on here? Any guidance is appreciated.