Framework (A-Z)

Reference for Wiring version 1.0 Build 0100+ If you have a previous version, use the reference included with your software. If see any errors or have any comments, let us know.

Name

shiftOut()

Examples
int data = 0;    // Wiring pin 0 for data 
int clock = 1;   // Wiring pin 1 for clock 
int strobe = 2;  // Wiring pin 2 for the strobe (latch) 
byte value = 0;

void setup() {
  pinMode(data, OUTPUT);
  pinMode(clock, OUTPUT);
  pinMode(strobe, OUTPUT);
}

void loop() { 
  // pulse the strobe or latch pin on the shift register
  digitalWrite(strobe, LOW);  
  // writes 'value' to the register
  shiftOut(data, clock, LSBFIRST, value);    
  digitalWrite(strobe, HIGH); 
  delay(1000);
  value = value + 1;
}
Description The shiftOut() method writes data to a pin one bit at a time. It can start from the most or the least significant bit (starts from leftmost or rightmost bit). This method is very useful to manage shift registers (output), which are devices that convert data from serial to parallel using one Wiring pin for sending data, one for the clock, and one for the strobe (latch).
Syntax
shiftOut(dataPin,clockPin,bitOrder,data)
shiftOut(dataPin,clockPin,bitOrder,data,count)
shiftOut(dataPin,clockPin,bitOrder,data,count,delayTime)
Parameters
dataPin int: the pin used to send out the data
clockPin int: the pin used as clock
bitOrder MSBFIRST or LSBFIRST: the bit order to use. MSBFIRST stands for most significant bit first (leftmost bit), LSBFIRST stands for less significant bit first (rightmost bit).
data byte or unsigned int: the data to send out. If no count specified a byte (8 bits) is assumed
count count: the number of bits to send (1 to 16).
delayTime delayTime: (optional parameter) delay in milliseconds for internally generate the clock pulse in the clockPin pin. This is useful for configuring the speed at which the shift register or a device can handle a new bit of a data.
Returns none
Usage Application
Related shiftIn()
MSBFIRST
LSBFIRST
Updated on July 07, 2011 11:08:58pm PDT

Creative Commons License