Hi,
I'm trying to program a string of leds to blink with a sn74hc595n.
I have 8 leds in total with the 74hc959 sinking each led, 220 resistor to each. OE is pulled to ground via resistor and srclk is to 5v. The breadboard is being sourced by a pickit2 at 5v. I'm using only the 1 shift register.
The problem is that all of the leds are on all the time. It doesn't seem to matter what i do to the code.
Also, i can't figure out why, except possibly that it's detecting a pulse(?) but when i jiggle the breadboard, or insert and remove power to the bb, some leds will turn off or all or none etc. I'm using an 18f2220. I have not tried the spi module or mikroc library as i wanted to get bit bang down first. a good portion of this code is not mine either, pieces were borrowed form several places. any advice/help would be appreciated
I'm trying to program a string of leds to blink with a sn74hc595n.
I have 8 leds in total with the 74hc959 sinking each led, 220 resistor to each. OE is pulled to ground via resistor and srclk is to 5v. The breadboard is being sourced by a pickit2 at 5v. I'm using only the 1 shift register.
The problem is that all of the leds are on all the time. It doesn't seem to matter what i do to the code.
Also, i can't figure out why, except possibly that it's detecting a pulse(?) but when i jiggle the breadboard, or insert and remove power to the bb, some leds will turn off or all or none etc. I'm using an 18f2220. I have not tried the spi module or mikroc library as i wanted to get bit bang down first. a good portion of this code is not mine either, pieces were borrowed form several places. any advice/help would be appreciated
Rich (BB code):
#define clock PORTB.F2
#define latch PORTB.F1
#define data PORTB.F0
void portOut (unsigned char buff)
{
unsigned int i;
unsigned char temp;
temp = buff;
i=8;
while (i>0)
{
if (temp==0) data = 0;
else data = 1;
temp = temp << 1;
clock = 1;
delay_us(1);
clock = 0;
i--;
}
latch = 1;
delay_us(1); // Latch the data
latch = 0;
}
void main()
{
TRISB = 0;
LATC=0;
delay_ms(85);
while(1)
{
portOut(170);
delay_ms(250);
portOut(0b11001100);
delay_ms(85);
}
}