Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
// connect 74HC595 reset to +5v, output enable to ground
char Dout = 0x55; // Data to shift to 74HC595
int i;
sbit Data at PORTB.B0; // pin 14 74HC595 Serial Data input
sbit Sc_cp at PORTB.B1; // pin 11 74HC595 Shift clock
sbit Tc_cp at PORTB.B2; // pin 12 74HC595 Latch clock
void shift_out( char dat )
{
Tc_cp = 0; // set latch clock to 0
for( i = 0; i < 8; i ++ )
{
Sc_cp = 0; // set shift clock to 0
Data = 0; // set Data to 0
if( (dat & 0x80) == 0x80) // check if bit 7 is a 1
Data = 1; // if bit 7 is a 1, set Data to 1
dat = (dat << 1); // shift Data out bit 7 first
Sc_cp= 1; // clock Data into shift register
}
Tc_cp = 1; // clock Data in shift register to 74HC595's outputs
}
void main()
{
TRISB = 0x00; // Configure PORTB as outputs
shift_out(Dout); // send 0x55 to 74HC595
while(1){}
}