User Manual

92
Experimental Procedures
Step 1: Build the circuit. If you want to take out the chip from the breadboard, DO NOT pull
it in one direction forcefully, for fear that the pins on it may be bent and you may get hurt.
Try to use a sharp tool to cross the notch of the breadboard to remove the chip.
For C language users:
Step 2: Get into the folder of the code.
cd /home/pi/SunFounder_Super_Kit_V3.0_for_Raspberry_Pi/C
Step 3: Compile
make 13_74HC595_LED
Step 4: Run the executable file above.
sudo ./13_74HC595_LED
Code Explanation
unsigned char LED[8] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80}; // This array is to
store the output values of Q0-Q7. For example, 0x01 in binary format is 0000 0001, thus
Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 are 0 0 0 0 0 0 0 1 respectively, that is Q0=1, and the LED
connected to Q0 will light up. Thus we can light up the eight LEDs separately in this
way.
void pulse(int pin){ // generate a rising edge
digitalWrite(pin, 0);
digitalWrite(pin, 1);
}
void SIPO(unsigned char byte){ // Assign the char byte to the SDI bit by bit
int i;
SunFounder