ShiftOut()

From Microduino Wiki
Jump to: navigation, search
void shiftOut (uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, byte val)    

The displacement output function

After value data is input, Arduino will automatically allocate the data to 8 parallel output ends, of which dataPin is the pin number of connecting to DS, clockPin is the pin number of connecting to SH_CP, bitOrder is to set the displacement data sequence, and they are respectively high first-in MSBFIRST or low first-in LSBFIRST.


  • Parameters:

dataPin

clockPin

bitOrder ( MSBFIRST or LSBFIRST)

val data

  • Example
// Do this for MSBFIRST serial
int data = 500;
// shift out highbyte
shiftOut(dataPin, clock, MSBFIRST, (data >> 8));  
// shift out lowbyte
shiftOut(dataPin, clock, MSBFIRST, data);

// Or do this for LSBFIRST serial
data = 500;
// shift out lowbyte
shiftOut(dataPin, clock, LSBFIRST, data);  
// shift out highbyte
shiftOut(dataPin, clock, LSBFIRST, (data >> 8)); 

[Return to Arduino Syntax Manual]