#define SHIFT_CLOCK PORTC.F2
#define SHIFT_LATCH PORTC.F1
#define SHIFT_DATA PORTC.F0
 
void shiftdata595(unsigned char _shiftdata)
{
unsigned int i;
unsigned char temp;
temp = _shiftdata;
i=8;
while (i>0)
{
if (temp.F7==0)
{
SHIFT_DATA = 0;
}
else
{
SHIFT_DATA = 1;
}
temp = temp<<1;
SHIFT_CLOCK = 1;
Delay_us(1);
SHIFT_CLOCK = 0;
i--;
}
}
 
void latch595()
{
SHIFT_LATCH = 1;
Delay_us(1);
SHIFT_LATCH = 0;
}
 
void main()
{
PORTC=0;
TRISC=0;
while(1)
{
shiftdata595(1);
latch595();
delay_ms(200);
 
shiftdata595(0x02);
latch595();
delay_ms(200);
 
shiftdata595(0b00000100);
latch595();
delay_ms(200);
}
}
