I think I ruined something, maybe my 74HC589. I left it running and had 2 LEDs turned on and at some point the LEDs went out. I tested the circuit with the shiftOutBlinkPlus sketches which showed that the HC595 and 4 LEDs were all working. Maybe I shorted the circuit some how, I dunno.
So I dismantled the circuit and bought some more LEDs and resistors, and redid the basic ShiftOutBlinkPlus circuit, but with 8 LEDs, called it ShiftOutBlinkPlus8.
This is pretty much the same as the code for the 4 bit version, except I changed the way I created the last few patterns.
Instead of this:
// shifts every other LED on and off
void eitherOr() {
// getting lazy about generating patterns algorithmically
// so just setting the nybbles by hand
bitWrite(pattern, 0, pos);
bitWrite(pattern, 1, neg);
bitWrite(pattern, 2, pos);
bitWrite(pattern, 3, neg);
displayPattern();
delay(delayCount);
bitWrite(pattern, 0, neg);
bitWrite(pattern, 1, pos);
bitWrite(pattern, 2, neg);
bitWrite(pattern, 3, pos);
displayPattern();
delay(delayCount);
}
I added a new helper method:
// return positive or negative pattern according to
// negation settings
byte posNegPattern(byte pattern) {
if (neg)
{
pattern = ~pattern;
}
return pattern;
}
And the pattern for 8 LEDs became this (the "0b" prefix indicates a binary number and, as you know, there are 10 types of people, those who know binary and those who do not):
void eitherOr() {
// getting lazy about generating patterns algorithmically
// so just setting the nybbles by hand
pattern = posNegPattern(0b10101010);
displayPattern();
delay(delayCount);
pattern = posNegPattern(0b01010101);
displayPattern();
delay(delayCount);
}
Next time I'll try building a circuit with only the HC589 and see if it still works.
No comments:
Post a Comment