shiftOut

位移输出函数,输入value数据后会自动把数据移动分配到8个并行输出端


语法
 void shiftOut(uint8 dataPin, uint8 clockPin, uint8 bitOrder, uint8 value)


参数


返回值


示例

uint16 data = 500;
shiftOut(dataPin, clockPin, MSBFIRST, (data >> 8));
shiftOut(dataPin, clockPin, MSBFIRST, data);


data = 500;
shiftOut(dataPin, clockPin, LSBFIRST, data);
shiftOut(dataPin, clockPin, LSBFIRST, (data >> 8));				
			

应用示例:74HC595

int latchPin = 8;
int clockPin = 12;
int dataPin = 11;

void setup() {
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
}

void loop() {
  for (int j = 0; j < 256; j++) {
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, LSBFIRST, j);
    digitalWrite(latchPin, HIGH);
    delay(1000);
  }
}