ShiftOut()
來自ALSROBOT WiKi
void shiftOut (uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, byte val)
位移輸出函數(shù)
輸入value數(shù)據(jù)后Arduino會自動把數(shù)據(jù)移動分配到8個并行輸出端. 其中dataPin為連接DS的引腳號, clockPin為連接SH_CP的引腳號, bitOrder為設置數(shù)據(jù)位移順序, 分別為高位先入MSBFIRST或者低位先入LSBFIRST.
參數(shù):
- dataPin 數(shù)據(jù)引腳
- clockPin 時鐘引腳
- bitOrder 移位順序 ( MSBFIRST 或 LSBFIRST)
- val 數(shù)據(jù)
// 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));