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 | shiftIn() |
||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
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) int value = 0; void setup() { pinMode(data INPUT); pinMode(clock, OUTPUT); // strobe or latch pin ona a shift register pinMode(strobe, OUTPUT); Serial.begin(9600); } void loop() { // pulse the strobe or latch pin on the shift register digitalWrite(strobe, LOW); // reads 8 bits (one byte) of data from the register value = shiftIn(data, clock, LSBFIRST, 8); digitalWrite(strobe, HIGH); Serial.println(value); delay(1000); } |
||||||||||
Description | The shiftIn() method reads data 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 (like CD4021), which are devices that convert data from parallel to serial using one Wiring pin for receiving data, one for the clock, and one for the strobe (latch). | ||||||||||
Syntax | shiftIn(dataPin,clockPin,bitOrder) shiftIn(dataPin,clockPin,bitOrder,count) shiftIn(dataPin,clockPin,bitOrder,count, delayTime) |
||||||||||
Parameters |
|
||||||||||
Returns | int: the data read from the pin | ||||||||||
Usage | Application | ||||||||||
Related | shiftOut() MSBFIRST LSBFIRST |