June 18, 2013, at 11:33 AM
by Alberto Cicchi -
Changed lines 9-14 from:
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.
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:
# Tell the register that I’m ready to get the information serially (latch pin LOW)
# For each of the inputs I’m expecting, pulse the clockPin and then check to see if the data pin is low or high
to:
# Tell the register that I'm ready to get the information serially (latch pin LOW)
# 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:
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.
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:
(:cell:) P1 – P8 (Pins 0-7)
to:
(:cell:) P1, P8 (Pins 0-7)
Changed lines 121-125 from:
[[ShftIn11 | Code Sample 1.1 – Hello World]]\\
[[ShftIn12 | Code Sample 1.2 – What is Pressed?]]\\
[[ShftIn13 | Code Sample 1.3 – Button Combination Check]]\\
[[ShftIn14 | Code Sample 1.4 – Is it pressed? (sub-function)]]\\
to:
[[ShftIn11 | Code Sample 1.1 Hello World]]\\
[[ShftIn12 | Code Sample 1.2 What is Pressed?]]\\
[[ShftIn13 | Code Sample 1.3 Button Combination Check]]\\
[[ShftIn14 | Code Sample 1.4 Is it pressed? (sub-function)]]\\
Changed lines 129-131 from:
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.
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:
[[shftIn21 | Code Sample 2.1 – Hello World]]\\
[[shftIn22 | Code Sample 2.2 – Using the second byte for settings, Print all]]\\
[[shftIn23 | Code Sample 2.3 – Using the second byte for settings, Print on only]] (uses sub-function)\\
to:
[[shftIn21 | Code Sample 2.1 Hello World]]\\
[[shftIn22 | Code Sample 2.2 Using the second byte for settings, Print all]]\\
[[shftIn23 | Code Sample 2.3 Using the second byte for settings, Print on only]] (uses sub-function)\\
February 08, 2007, at 01:00 PM
by Carlyn Maw -
Changed lines 9-12 from:
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 open or closed 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 cord. “Asynchronous” because the CD4021B is doing all this data collection without coordinating with the Arduino board at all.
Those 8 pin states are then 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. This Arduino pin is the first of the 3 pins mentioned in the first paragraph and it will be 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.”
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.”
February 07, 2007, at 08:40 PM
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 07, 2007, at 08:36 PM
by Carlyn Maw -
Changed lines 60-61 from:
There is more information about shifting in the [[Tutorials/ShiftOut]] tutorial, and before you start wiring up your board here is the pin diagram of the CD4021 from the [[Attach:TI_CD4021.pdf | Texas Instruments Datasheet]]
to:
There is more information about shifting in the [[Tutorial/ShiftOut]] tutorial, and before you start wiring up your board here is the pin diagram of the CD4021 from the [[Attach:TI_CD4021.pdf | Texas Instruments Datasheet]]
February 07, 2007, at 08:36 PM
by Carlyn Maw -
Changed lines 9-14 from:
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 open or closed 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 cord. “Asynchronous” because it is doing all this data collection without regard to coordinating its listening rate with the Arduino board at all.
Those 8 pin states are then translated into a series of high and low pulses received by pin on your Arduino Board, the '''data pin'''. This is called Synchronous Serial Output because the shift register waits to deliver this linear sequence 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 latchPin 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.
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 open or closed 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 cord. “Asynchronous” because the CD4021B is doing all this data collection without coordinating with the Arduino board at all.
Those 8 pin states are then 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. This Arduino pin is the first of the 3 pins mentioned in the first paragraph and it will be 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.
February 07, 2007, at 08:25 PM
by Carlyn Maw -
February 07, 2007, at 08:25 PM
by Carlyn Maw -
Changed lines 33-34 from:
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 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.
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.
February 07, 2007, at 08:24 PM
by Carlyn Maw -
Changed lines 7-16 from:
A standard piano has 88 keys. There are 104 keys on the US English QWERTY extended PC keyboard. Even the most basic mobile phones has at least 15 buttons. Meanwhile, an Arduino has just the 13 digital pins. Not to worry, that is what shift-registers are for and the Parallel to Serial kind are meant for just this kind of digital-input expansion.
The CD4021B type registers are “8-Stage Static Shift Registers.” They can handle Asynchronous Parallel Input, Synchronous Serial Input and Synchronous Serial Output. This means you can read the open or closed state of 8 switches attached to the register all at once and then translate that information into a sequence of highs and lows to be read by your Arduino Board. This is a bit like describing a picture tosomeone on the other end of telephone. If supplementing your Arduino with an additional 8 digital-ins isn’t going to be enough for your project you can have a second CD4021B pass its information on to that first CD4021 which then hands off all 16 bits of information to the Arduino in turn. 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. (what is the theoretical/practical limit?)
Reading the switch states all at once is the “Asynchronous Parallel Input” part. “Input” because you are collecting information. “Parallel” because it is all at once – like hearing a cord. “Asynchronous” because it is doing all this data collection without regard to coordinating its listening rate with the Arduino board at all.
This works because the Arduino ultimately receives the information about the pin states through the “Synchronous Serial Output” capacity of the shift register. 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.”
There is also a “Parallel to Serial Control” pin. You can think of it as a “latchPin.” When the latchPin is HIGH the shift register is listening to its 8 parallel ins. When it is LOW it is listening to the clockPin and passing information serially. That means every time the latchPin transitions from HIGH to LOW the shift register will start passing its most current switch information.
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.
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 open or closed 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 cord. “Asynchronous” because it is doing all this data collection without regard to coordinating its listening rate with the Arduino board at all.
Those 8 pin states are then translated into a series of high and low pulses received by pin on your Arduino Board, the '''data pin'''. This is called Synchronous Serial Output because the shift register waits to deliver this linear sequence 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 latchPin 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 16-21 from:
# Tell the register to look at its parallel inputs (latchPin HIGH)
# Tell the register that I’m ready to get the information serially (latchPin LOW)
# For the number of bits I’m expecting (for i=0, i<=number-of-inputs, i++), pulse the clockPin and then check if the dataPin low or high
Example 1 puts it all into action, but before you start wiring up your board here is the pin diagram of the CD4021 from the [[Attach:TI_CD4021.pdf | Texas Instruments Datasheet]]
to:
# Make sure the register has the latest information from its parallel inputs (i.e. that the latch pin is HIGH)
# Tell the register that I’m ready to get the information serially (latch pin LOW)
# For each of the inputs I’m expecting, pulse the clockPin and then check to see if the data pin is low or high
This is a basic diagram.
[@ _______
switch -> | |
switch -> | C |
switch -> | D |
switch -> | 4 | -> Serial Data to Arduino
switch -> | 0 |
switch -> | 2 |
switch -> | 1 | <- Clock Data from Arduino
switch -> |_____| <- Latch Data from Arduino
@]
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 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.
[@
_______
switch -> | |
switch -> | C |
switch -> | D |
switch -> | 4 | -> Serial Data to Arduino
switch -> | 0 |
switch -> | 2 | <- Clock Data from Arduino
switch -> | 1 | <- Latch Data from Arduino
switch -> |_____| <------
|
|
|
_______ | Serial Data Passed to First
switch -> | | | Shift Register
switch -> | C | |
switch -> | D | |
switch -> | 4 | ______|
switch -> | 0 |
switch -> | 2 | <- Clock Data from Arduino
switch -> | 1 | <- Latch Data from Arduino
switch -> |_____|
@]
There is more information about shifting in the [[Tutorials/ShiftOut]] tutorial, and before you start wiring up your board here is the pin diagram of the CD4021 from the [[Attach:TI_CD4021.pdf | Texas Instruments Datasheet]]
February 06, 2007, at 07:14 PM
by Carlyn Maw -
Changed line 119 from:
[[shftIn23 | Code Sample 2.3 – Using the second byte for settings, Print on only]]\\
to:
[[shftIn23 | Code Sample 2.3 – Using the second byte for settings, Print on only]] (uses sub-function)\\
February 06, 2007, at 07:13 PM
by Carlyn Maw -
Changed lines 83-87 from:
[[ShftIn1_1 | Code Sample 1.1 – Hello World]]\\
[[ShftIn1_2 | Code Sample 1.2 – What is Pressed?]]\\
[[ShftIn1_3 | Code Sample 1.3 – Button Combination Check]]\\
[[ShftIn1_4 | Code Sample 1.4 – Is it pressed? (sub-function)]]\\
to:
[[ShftIn11 | Code Sample 1.1 – Hello World]]\\
[[ShftIn12 | Code Sample 1.2 – What is Pressed?]]\\
[[ShftIn13 | Code Sample 1.3 – Button Combination Check]]\\
[[ShftIn14 | Code Sample 1.4 – Is it pressed? (sub-function)]]\\
Changed lines 117-118 from:
[[shftIn2_1 | Code Sample 2.1 – Hello World]]\\
[[shftIn2_2 | Code Sample 2.2 – Using the second byte for settings]]\\
to:
[[shftIn21 | Code Sample 2.1 – Hello World]]\\
[[shftIn22 | Code Sample 2.2 – Using the second byte for settings, Print all]]\\
[[shftIn23 | Code Sample 2.3 – Using the second byte for settings, Print on only]]\\
February 06, 2007, at 06:51 PM
by Carlyn Maw -
February 06, 2007, at 06:51 PM
by Carlyn Maw -
Changed lines 61-62 from:
%width=600px% http://www.arduino.cc/en/uploads/Tutorial/ShftInExmp1_Schem.png
to:
Changed lines 79-80 from:
Attach:ShftInExmp1_Schem.png
to:
%width=600px% http://www.arduino.cc/en/uploads/Tutorial/ShftInExmp1_Schem.png
February 06, 2007, at 06:51 PM
by Carlyn Maw -
February 06, 2007, at 06:50 PM
by Carlyn Maw -
February 06, 2007, at 06:47 PM
by Carlyn Maw -
Changed lines 20-24 from:
# for the number of bits I’m expecting (for i=0, i<=number of inputs, i++) -- is the datPin low or high? (read dataPin)
# tell the register to go back to looking at its parallel inputs (latchPin HIGH)
Example 1 puts it all into action, but before you start wiring up your board here is the pin diagram of the CD4021 from the Texas Instruments Datasheet
to:
# For the number of bits I’m expecting (for i=0, i<=number-of-inputs, i++), pulse the clockPin and then check if the dataPin low or high
Example 1 puts it all into action, but before you start wiring up your board here is the pin diagram of the CD4021 from the [[Attach:TI_CD4021.pdf | Texas Instruments Datasheet]]
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 06, 2007, at 06:36 PM
by Carlyn Maw -
Changed lines 62-63 from:
to:
%width=600px% http://www.arduino.cc/en/uploads/Tutorial/ShftInExmp1_Schem.png
February 06, 2007, at 06:35 PM
by Carlyn Maw -
Changed lines 80-81 from:
Attach:ShftInExmp1_Schem.gif
to:
Attach:ShftInExmp1_Schem.png
Changed lines 112-113 from:
%width=600px% http://www.arduino.cc/en/uploads/Tutorial/ShftInExmp2_Schem.gif
to:
%width=600px% http://www.arduino.cc/en/uploads/Tutorial/ShftInExmp2_Schem.png
February 06, 2007, at 06:08 PM
by Carlyn Maw -
Changed lines 112-113 from:
Attach:ShftInExmp2_Schem.gif
to:
%width=600px% http://www.arduino.cc/en/uploads/Tutorial/ShftInExmp2_Schem.gif
February 06, 2007, at 06:07 PM
by Carlyn Maw -
Changed line 26 from:
(:cell rowspan=9 :) %width=200px% http://www.arduino.cc/en/uploads/Tutorial/shftin_cd4021_pins.png
to:
(:cell rowspan=9 :) %width=300px% http://www.arduino.cc/en/uploads/Tutorial/shftin_cd4021_pins.png
February 06, 2007, at 06:07 PM
by Carlyn Maw -
Changed line 26 from:
(:cell rowspan=9 :)Attach:shftin_cd4021_pins.png
to:
(:cell rowspan=9 :) %width=200px% http://www.arduino.cc/en/uploads/Tutorial/shftin_cd4021_pins.png
February 06, 2007, at 05:56 PM
by Carlyn Maw -
Changed lines 84-88 from:
[[shftIn1_1 | Code Sample 1.1 – Hello World]]\\
[[shftIn1_2 | Code Sample 1.2 – What is Pressed?]]\\
[[shftIn1_3 | Code Sample 1.3 – Button Combination Check]]\\
[[shftIn1_3 | Code Sample 1.4 – Is it pressed? (sub-function)]]\\
to:
[[ShftIn1_1 | Code Sample 1.1 – Hello World]]\\
[[ShftIn1_2 | Code Sample 1.2 – What is Pressed?]]\\
[[ShftIn1_3 | Code Sample 1.3 – Button Combination Check]]\\
[[ShftIn1_4 | Code Sample 1.4 – Is it pressed? (sub-function)]]\\
Changed lines 99-100 from:
to:
Changed lines 104-105 from:
to:
Changed lines 108-109 from:
to:
February 06, 2007, at 05:55 PM
by Carlyn Maw -
Changed lines 80-81 from:
Attach:ShftInExmp1_Schem.png
to:
Attach:ShftInExmp1_Schem.gif
February 06, 2007, at 05: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:
Attach:ShftInExmp1_Schem.gif
to:
Attach:ShftInExmp1_Schem.png
February 06, 2007, at 05:50 PM
by Carlyn Maw -
Changed lines 84-88 from:
[[shiftOut1_1 | Code Sample 1.1 – Hello World]]\\
[[shiftOut1_2 | Code Sample 1.2 – What is Pressed?]]\\
[[shiftOut1_3 | Code Sample 1.3 – Button Combination Check]]\\
[[shiftOut1_3 | Code Sample 1.4 – Is it pressed? (sub-function)]]\\
to:
[[shftIn1_1 | Code Sample 1.1 – Hello World]]\\
[[shftIn1_2 | Code Sample 1.2 – What is Pressed?]]\\
[[shftIn1_3 | Code Sample 1.3 – Button Combination Check]]\\
[[shftIn1_3 | Code Sample 1.4 – Is it pressed? (sub-function)]]\\
Changed lines 116-117 from:
[[shiftOut2_1 | Code Sample 2.1 – Hello World]]\\
[[shiftOut2_2 | Code Sample 2.2 – Using the second byte for settings]]\\
to:
[[shftIn2_1 | Code Sample 2.1 – Hello World]]\\
[[shftIn2_2 | Code Sample 2.2 – Using the second byte for settings]]\\
February 06, 2007, at 04: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 04:12 PM
by Carlyn Maw -
February 06, 2007, at 04:11 PM
by Carlyn Maw -
Added lines 108-114:
Attach:ShftInExmp2_Schem.gif
!!!The Code
[[shiftOut2_1 | Code Sample 2.1 – Hello World]]\\
[[shiftOut2_2 | Code Sample 2.2 – Using the second byte for settings]]\\
February 06, 2007, at 04:09 PM
by Carlyn Maw -
Changed lines 81-82 from:
to:
Added lines 90-108:
!!Example 2: Daisy Chained
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.
!!!The Circuit
!!!!1. Add a second shift register.
!!!!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.
!!!!3. Add a second set of Switches.
!!!!Diagram
February 06, 2007, at 04:07 PM
by Carlyn Maw -
Added lines 81-89:
!!!!Code Examples
[[shiftOut1_1 | Code Sample 1.1 – Hello World]]\\
[[shiftOut1_2 | Code Sample 1.2 – What is Pressed?]]\\
[[shiftOut1_3 | Code Sample 1.3 – Button Combination Check]]\\
[[shiftOut1_3 | Code Sample 1.4 – Is it pressed? (sub-function)]]\\
[[<<]]
February 06, 2007, at 04: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
Attach:ShftInExmp1_Schem.gif
February 06, 2007, at 04: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:
(:table border=1 bordercolor=#CCCCCC cellpadding=5 cellspacing=0:)
(:cell rowspan=9 :)Attach:shftin_cd4021_pins.png
(:cell:) PINS 1,4-7, 13-15
(:cell:) P1 – P8 (Pins 0-7)
(:cell:) Parallel Inputs
(:cellnr:) PINS 2, 12, 3
(:cell:) Q6, Q7, Q8
(:cell:) Serial Output Pins from different steps in the sequence. Q7 is a pulse behind Q8 and Q6 is a pulse behind Q7. Q8 is the only one used in these examples.
(:cellnr:) PIN 8
(:cell:) Vss
(:cell:) GND
(:cellnr:) PIN 9
(:cell:) P/S C
(:cell:) Parallel/Serial Control (latch pin)
(:cellnr:) PIN 10
(:cell:) CLOCK
(:cell:) Shift register clock pin
(:cellnr:) PIN 11
(:cell:) SERIAL-IN
(:cell:) Serial data input
(:cellnr:) PIN 16
(:cell:) VDD
(:cell:) DC supply voltage
February 06, 2007, at 03: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:
1. Tell the register to look at its parallel inputs (latchPin HIGH)
2. Tell the register that I’m ready to get the information serially (latchPin LOW)
3. for the number of bits I’m expecting (for i=0, i<=number of inputs, i++)
• is the datPin low or high? (read dataPin)
4. tell the register to go back to looking at its parallel inputs (latchPin HIGH)
to:
# Tell the register to look at its parallel inputs (latchPin HIGH)
# Tell the register that I’m ready to get the information serially (latchPin LOW)
# for the number of bits I’m expecting (for i=0, i<=number of inputs, i++) -- is the datPin low or high? (read dataPin)
# tell the register to go back to looking at its parallel inputs (latchPin HIGH)
February 06, 2007, at 03:51 PM
by Carlyn Maw -
Added lines 1-13:
Shifting In & the CD4021B
A standard piano has 88 keys. There are 104 keys on the US English QWERTY extended PC keyboard. Even the most basic mobile phones has at least 15 buttons. Meanwhile, an Arduino has just the 13 digital pins. Not to worry, that is what shift-registers are for and the Parallel to Serial kind are meant for just this kind of digital-input expansion.
The CD4021B type registers are “8-Stage Static Shift Registers.” They can handle Asynchronous Parallel Input, Synchronous Serial Input and Synchronous Serial Output. This means you can read the open or closed state of 8 switches attached to the register all at once and then translate that information into a sequence of highs and lows to be read by your Arduino Board. This is a bit like describing a picture tosomeone on the other end of telephone. If supplementing your Arduino with an additional 8 digital-ins isn’t going to be enough for your project you can have a second CD4021B pass its information on to that first CD4021 which then hands off all 16 bits of information to the Arduino in turn. 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. (what is the theoretical/practical limit?)
Reading the switch states all at once is the “Asynchronous Parallel Input” part. “Input” because you are collecting information. “Parallel” because it is all at once – like hearing a cord. “Asynchronous” because it is doing all this data collection without regard to coordinating its listening rate with the Arduino board at all.
This works because the Arduino ultimately receives the information about the pin states through the “Synchronous Serial Output” capacity of the shift register. 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.”
There is also a “Parallel to Serial Control” pin. You can think of it as a “latchPin.” When the latchPin is HIGH the shift register is listening to its 8 parallel ins. When it is LOW it is listening to the clockPin and passing information serially. That means every time the latchPin transitions from HIGH to LOW the shift register will start passing its most current switch information.
The pseudo code to coordinate this all looks something like this:
1. Tell the register to look at its parallel inputs (latchPin HIGH)
2. Tell the register that I’m ready to get the information serially (latchPin LOW)
3. for the number of bits I’m expecting (for i=0, i<=number of inputs, i++)
• is the datPin low or high? (read dataPin)
4. tell the register to go back to looking at its parallel inputs (latchPin HIGH)
Example 1 puts it all into action, but before you start wiring up your board here is the pin diagram of the CD4021 from the Texas Instruments Datasheet