read
Read data from shift register
Description
Examples
Read Data from a Shift Register
Create an Arduino® object with the 'ShiftRegister'
library.
a = arduino('COM4','Uno','Libraries','ShiftRegister');
Connect to the 8-bit PISO shift register on your Arduino board.
register = shiftRegister(a,'74HC165','D3','D6','D7','D10');
Read data from the data pin of the register.
out = read(register)
out = 1×8
1 1 1 1 1 0 0 0
Specify Precision to Read Data
Specify the data precision to read data from the data pin of a PISO shift register.
Create an Arduino® object with the 'ShiftRegister'
library.
a = arduino('COM4','Uno','Libraries','ShiftRegister');
Connect to the 8-bit PISO shift register on your Arduino board.
register = shiftRegister(a,'74HC165','D3','D6','D7','D10');
You can specify the precision as 'uint8'
to read data from the register.
out = read(register,'uint8')
out = 0
Or you can specify the precision as a multiple of 8.
out = read(register,8)
out = 1×8
0 0 0 0 0 0 0 0
Input Arguments
register
— Shift register connection
shiftRegister object
Shift register connection, specified as a shiftRegister object.
precision
— Data precision
8 (default) | 16 | 24 | 32 | 'uint8'
| 'uint16'
| 'uint32'
Data precision, specified as one of the following multiples of 8:
8
16
24
32
or as one of the following character vectors:
'uint8'
'uint16'
'uint32'
The default precision is 8. The precision value cannot exceed the number of inputs of the shift register. For a single chip, the number of inputs is eight. For chained shift registers, the number of inputs is eight times the number of registers.
Output Arguments
out
— Data read
double scalar | double vector
Data read from the data pin of a PISO shift register, returned as a double scalar or vector.
Version History
Introduced in R2016b
See Also
arduino
| shiftRegister
| write
| reset
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)