Tutorial.ShiftIn History

Hide minor edits - Show changes to markup

June 18, 2013, at 05:33 PM by Alberto Cicchi -
Changed lines 9-14 from:
to:

An example of a parallel to serial register is the CD4021B, sometimes referred to as an 8-Stage Static Shift Register. This means you can read the state of up to 8 digital inputs attached to the register all at once. This is called Asynchronous Parallel Input. "Input" because you are collecting information. "Parallel" because it is all at once, like hearing a musical cord. "Asynchronous" because the CD4021B is doing all this data collection at its own pace without coordinating with the Arduino.

That happens in the next step when those 8 pin states are translated into a series of HIGH and LOW pulses on the serial-out pin of the shift register. This pin should be connected to an input pin on your Arduino Board, referred to as the data pin. The transfer of information itself is called Synchronous Serial Output because the shift register waits to deliver linear sequence of data to the Arduino until the Arduino asks for it. Synchronous Serial communication, input or output, is heavily reliant on what is referred to as a clock pin. That is what makes it synchronous. The clock pin is the metronome of the conversation between the shift register and the Arduino. Every time the Arduino sends the clock pin from LOW to HIGH it is telling the shift register change the state of your Serial Output pin to tell me about the next switch.

The third pin attached to the Arduino is a "Parallel to Serial Control" pin. You can think of it as a latch pin. When the latch pin is HIGH the shift register is listening to its 8 parallel ins. When it is LOW it is listening to the clock pin and passing information serially. That means every time the latch pin transitions from HIGH to LOW the shift register will start passing its most current switch information.

Changed lines 17-19 from:
to:
  1. Tell the register that I'm ready to get the information serially (latch pin LOW)
  2. For each of the inputs I'm expecting, pulse the clockPin and then check to see if the data pin is low or high
Changed lines 33-34 from:
to:

If supplementing your Arduino with an additional 8 digital-ins isn't going to be enough for your project you can have a second CD4021 pass its information on to that first CD4021 which will then be streaming all 16 bits of information to the Arduino in turn. If you know you will need to use multiple shift registers like this check that any shift registers you buy can handle Synchronous Serial Input as well as the standard Synchronous Serial Output capability. Synchronous Serial Input is the feature that allows the first shift register to receive and transmit the serial-output from the second one linked to it. The second example will cover this situation. You can keep extending this daisy-chain of shift registers until you have all the inputs you need, within reason.

Changed line 65 from:
to:
Changed lines 121-125 from:
to:
Changed lines 129-131 from:
to:

In this example you'll add a second shift register, doubling the number of input pins while still using the same number of pins on the Arduino.

Changed lines 155-157 from:
to:
February 08, 2007, at 07:00 PM by Carlyn Maw -
Changed lines 9-12 from:
to:
February 08, 2007, at 02:40 AM by Carlyn Maw -
Changed lines 7-8 from:

Sometimes you'll end up needing more digital input than the 13 pins on your Arduino board can readily handle. Using a parallel to serial shift register allows you collect information from 8 or more switches while only using 3 of the pins on your Arduino.

to:

Sometimes you'll end up needing more digital input than the 13 pins on your Arduino board can readily handle. Using a parallel to serial shift register allows you collect information from 8 or more switches while only using 3 of the pins on your Arduino.

February 08, 2007, at 02:36 AM by Carlyn Maw -
Changed lines 60-61 from:

There is more information about shifting in the ShiftOut? tutorial, and before you start wiring up your board here is the pin diagram of the CD4021 from the Texas Instruments Datasheet

to:

There is more information about shifting in the ShiftOut tutorial, and before you start wiring up your board here is the pin diagram of the CD4021 from the Texas Instruments Datasheet

February 08, 2007, at 02:36 AM by Carlyn Maw -
Changed lines 9-14 from:
to:
February 08, 2007, at 02:25 AM by Carlyn Maw -
February 08, 2007, at 02:25 AM by Carlyn Maw -
Changed lines 33-34 from:
to:
February 08, 2007, at 02:24 AM by Carlyn Maw -
Changed lines 7-16 from:
to:
Changed lines 16-21 from:
to:
February 07, 2007, at 01:14 AM by Carlyn Maw -
Changed line 119 from:
to:
February 07, 2007, at 01:13 AM by Carlyn Maw -
Changed lines 83-87 from:
to:
Changed lines 117-118 from:
to:
February 07, 2007, at 12:51 AM by Carlyn Maw -
February 07, 2007, at 12:51 AM by Carlyn Maw -
Changed lines 61-62 from:

http://www.arduino.cc/en/uploads/Tutorial/ShftInExmp1_Schem.png

to:
Changed lines 79-80 from:
to:

http://www.arduino.cc/en/uploads/Tutorial/ShftInExmp1_Schem.png

February 07, 2007, at 12:51 AM by Carlyn Maw -
February 07, 2007, at 12:50 AM by Carlyn Maw -
February 07, 2007, at 12:47 AM by Carlyn Maw -
Changed lines 20-24 from:
to:
Added lines 107-108:

Notice that there is one momentary switch and the rest are toggle switches. This is because the code examples will be using the switches attached to the second shift register as settings, like a preference file, rather than as event triggers. The one momentary switch will be telling the microcontroller that the setting switches are being changed.

February 07, 2007, at 12:36 AM by Carlyn Maw -
Changed lines 62-63 from:
to:

http://www.arduino.cc/en/uploads/Tutorial/ShftInExmp1_Schem.png

February 07, 2007, at 12:35 AM by Carlyn Maw -
Changed lines 80-81 from:
to:
Changed lines 112-113 from:

http://www.arduino.cc/en/uploads/Tutorial/ShftInExmp2_Schem.gif

to:

http://www.arduino.cc/en/uploads/Tutorial/ShftInExmp2_Schem.png

February 07, 2007, at 12:08 AM by Carlyn Maw -
Changed lines 112-113 from:
to:

http://www.arduino.cc/en/uploads/Tutorial/ShftInExmp2_Schem.gif

February 07, 2007, at 12:07 AM by Carlyn Maw -
Changed line 26 from:
to:
February 07, 2007, at 12:07 AM by Carlyn Maw -
Changed line 26 from:
to:
February 06, 2007, at 11:56 PM by Carlyn Maw -
Changed lines 84-88 from:
to:
Changed lines 99-100 from:
to:
Changed lines 104-105 from:
to:
Changed lines 108-109 from:
to:
February 06, 2007, at 11:55 PM by Carlyn Maw -
Changed lines 80-81 from:
to:
February 06, 2007, at 11:52 PM by Carlyn Maw -
Changed lines 62-63 from:
to:
Changed lines 72-73 from:
to:
Changed lines 76-77 from:
to:
Changed lines 80-81 from:
to:
February 06, 2007, at 11:50 PM by Carlyn Maw -
Changed lines 84-88 from:
to:
Changed lines 116-117 from:
to:
February 06, 2007, at 10:13 PM by Carlyn Maw -
Changed lines 48-49 from:
to:
Added lines 99-102:

Attach:ShftInExmp2_1.gif Δ

2. Connect the 2 registers.

Two of these connections simply extend the same clock and latch signal from the Arduino to the second shift register (yellow and green wires). The blue wire is going from the serial out pin (pin 9) of the first shift register to the serial data input (pin 14) of the second register.

Changed lines 104-108 from:

2. Connect the 2 registers.

Two of these connections simply extend the same clock and latch signal from the Arduino to the second shift register (yellow and green wires). The blue wire is going from the serial out pin (pin 9) of the first shift register to the serial data input (pin 14) of the second register.

to:
Changed lines 108-109 from:
to:
February 06, 2007, at 10:12 PM by Carlyn Maw -
February 06, 2007, at 10:11 PM by Carlyn Maw -
Added lines 108-114:
February 06, 2007, at 10:09 PM by Carlyn Maw -
Changed lines 81-82 from:

Code Examples

to:

The Code

Added lines 90-108:
February 06, 2007, at 10:07 PM by Carlyn Maw -
Added lines 81-89:
February 06, 2007, at 10:05 PM by Carlyn Maw -
Added lines 49-80:

Example 1: One Shift Register

The first step is to extend your Arduino with one shift register.

The Circuit

1. Power Connections

Make the following connections:

  • GND (pin 8) to ground,
  • VDD (pin 16) to 5V

Attach:ShftInExmp1_1.gif Δ

2.Connect to Arduino

  • Q8 (pin 3) to Ardunio DigitalPin 9 (blue wire)
  • CLOCK (pin 10) to to Ardunio DigitalPin 7 (yellow wire)
  • P/S C (pin 9) to Ardunio DigitalPin 8 (green wire)

From now on those will be refered to as the dataPin, the clockPin and the latchPin respectively.

Attach:ShftInExmp1_2.gif Δ

3. Add 8 Switches

Attach:ShftInExmp1_3.gif Δ

Diagram

February 06, 2007, at 10:01 PM by Carlyn Maw -
Added lines 1-4:

Parallel to Serial Shifting-In with a CD4021BE

Started By Carlyn Maw and Tom Igoe Jan, '07

Added lines 24-48:
February 06, 2007, at 09:54 PM by Carlyn Maw -
Changed lines 1-2 from:

Shifting In & the CD4021B

to:

Shifting In & the CD4021B

Added line 4:
Added line 6:
Added line 8:
Added line 10:
Added line 12:
Changed lines 14-18 from:
to:
February 06, 2007, at 09:51 PM by Carlyn Maw -
Added lines 1-13:

Share