Code 
In this project, make a flowing water light with 74HC595 to learn its usage. 
C Code 17.1.1 LightWater02 
First observe the project result, and then analyze the code. 
1.  Use cd command to enter 17.1.1_LightWater02  directory of C code. 
cd ~/Freenove_Ultimate_Starter_Kit_for_Raspberry_Pi/Code/C_Code/17.1.1_LightWater02 
2.  Use following command to compile “LightWater02.c” and generate executable file “LightWater02”. 
gcc LightWater02.c -o LightWater02 -lwiringPi 
3.  Then run the generated file “LightWater02”. 
sudo ./LightWater02 
After the program is executed, LEDBar Graph begin to display flowing water light from left to right, then from 
right to left. 
The following is the program code: 
#include <wiringPi.h> 
#include <stdio.h> 
#include <wiringShift.h> 
 
#define   dataPin  0   //DS Pin of 74HC595(Pin14) 
#define   latchPin  2  //ST_CP Pin of 74HC595(Pin12) 
#define   clockPin 3   //SH_CP Pin of 74HC595(Pin11) 
 
void _shiftOut(int dPin,int cPin,int order,int val){    
    int i;    
    for(i = 0; i < 8; i++ ){ 
        digitalWrite(cPin,LOW); 
        if(order == LSBFIRST){ 
            digitalWrite(dPin,((0x01&(val>>i)) == 0x01) ? HIGH :  LOW); 
            delayMicroseconds(10); 
        } 
        else {//if(order == MSBFIRST){ 
            digitalWrite(dPin,((0x80&(val<<i)) == 0x80) ? HIGH :  LOW); 
            delayMicroseconds(10); 
        } 
        digitalWrite(cPin,HIGH); 
        delayMicroseconds(10); 
    }  
} 
 
int main( void) 
{ 
    int i;  
    unsigned char x;