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
Ouvrir l'exemple
Vous possédez une version modifiée de cet exemple. Souhaitez-vous ouvrir cet exemple avec vos modifications ?
Commande MATLAB
Vous avez cliqué sur un lien qui correspond à cette commande MATLAB :
Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes MATLAB.
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)