
HIGH or LOW in exactly the same way that you use digitalWrite(). This function lets you make the shift register outputs Void shiftWrite(int desiredPin, boolean desiredState) binar圜ount() // Bit patterns from 0 to 255 pingPong() // Like above, but back and forth you want to run, and comment out the remaining ones to To try the different functions below, uncomment the one We also have a new function that demonstrates digitalWrite() with a new function called shiftWrite() in circuit 04, "Multiple LEDs", we've just replaced We're going to use the same functions we played with back We'll also declare a global variable for the data we're (Serial Peripheral Interface) that requires three pins:
#SHIFT REGISTER USING SPI ARDUINO SERIAL#
The 74HC595 uses a type of serial connection called SPI This code is completely free for any use. With lots of help from the Arduino community. This sketch was written by SparkFun Electronics, Legs of the LEDs, connect the negative side (short lead) ofĮach LED to a 330 Ohm resistor, and connect the other side See the datasheet aboveĪfter making the above connections to the positive (longer) They are numberedĬounterclockwise starting at the pin 1 mark (notch Plug in the chip so it bridges the center "canyon" The same three Arduino pins! See the shift register datasheet Together, allowing an almost unlimited number of outputs from And if you needĮven more outputs, you can daisy-chain multiple shift registers This IC lets you use three digital pins on your Arduino toĬontrol eight digital outputs on the chip. ShiftIn() and shiftOut() to access these parts. Many parts use SPIįor communications, so the Arduino offers simple commands called RX you're used to, but has an additional "clock" line thatĬontrols the speed of the data transfer. To use these outputs, we'll use a new interfaceĬalled SPI (Serial Peripheral Interface). The 74HC595 shift register in your kit is an IC that has eightĭigital outputs. Thousands of different types of ICs available that you can use (If you look closelyĪt your Arduino board you'll see a number of ICs.) There are Use a shift register to turn three pins into eight (or more!)Īn integrated circuit ("IC"), or "chip", is a self-containedĬircuit built into a small plastic package. Hit upload, and see what happens! language:cpp

You can also copy and paste the following code into the Arduino IDE. To open the code go to: File > examples > SIK Guide Code > Circuit_14

Open the code for Circuit 14 by accessing the “SIK Guide Code” you downloaded and placed into your “Examples” folder earlier. Coding in the Arduino language will control your circuit.
#SHIFT REGISTER USING SPI ARDUINO SOFTWARE#
Open Up the Arduino IDE software on your computer. Having a hard time seeing the circuit? Click on the Fritzing diagram to see a bigger image.
