After much experimentation, I have finally given up and registered here in the hopes that someone can tell me what I'm doing wrong. So, first post, I'm a super newbie, etc., etc.
I have an (older) Arduino Duemilanove and I'm muddling through controlling a King Electronics MBI5027GN 16-bit LED shift register. The problem that I'm having is that I can't get the very first LED nor the very last LED to light.
I can shift in various patterns and make the other lamps stay lit, but when I try to shift in 1 or 32768, they don't light. The very last lamp (32768) will blink once very quickly rather than staying on if its bit is set.
I'm not sure if this is a problem with my (admittedly cheap) MBI5027 and I should just get a nicer, newer, better shift register, or if I'm doing something entirely wrong. Here is the code I'm running:
int SDIPIN = 0;
int CLKPIN = 1;
int LEPIN = 2;
void setup() {
pinMode(SDIPIN, OUTPUT);
pinMode(CLKPIN, OUTPUT);
pinMode(LEPIN, OUTPUT);
digitalWrite(LEPIN, LOW);
delay(5000);
}
void shift_out_16(unsigned int v) {
long n;
digitalWrite(CLKPIN, LOW); // be sure CLK is idle at zero
digitalWrite(LEPIN, LOW);
for (n=0; n<16; n++)
{
if (v >> (15 - n) & 0x1) // most significant bit first
{
digitalWrite(SDIPIN, HIGH);
} else {
digitalWrite(SDIPIN, LOW);
}
digitalWrite(CLKPIN, HIGH);
digitalWrite(CLKPIN, LOW);
}
digitalWrite(LEPIN, HIGH);
}
void loop()
{
shift_out_16(32769);
delay(1000);
}
32769 should light the first and last lamps, correct? I have used values like 1056, which lights the sixth and eleventh, and those values work just fine. The lamps are bright, no flicker, everything is great.
So what's up with out 0 and out 15?