write
Write data to shift register
Add-On Required: This feature requires the MATLAB Support Package for Arduino Hardware add-on.
Description
Examples
Write Data to a Shift Register
Create an Arduino® object with the 'ShiftRegister'
library.
a = arduino('COM4','Uno','Libraries','ShiftRegister');
Connect to the SIPO shift register on your Arduino board.
register = shiftRegister(a,'74HC595','D3','D6','D7');
Write data to the data pin of the register.
write(register,23);
Specify Precision to Write Data
Create an Arduino® object with the 'ShiftRegister'
library.
a = arduino('COM4','Uno','Libraries','ShiftRegister');
Connect to the SIPO shift register on your Arduino board.
register = shiftRegister(a,'74HC595','D3','D6','D7');
Write data to the data pin of the register with a specified precision.
write(register,300,'uint16');
Input Arguments
register
— Shift register connection
shiftRegister object
Shift register connection, specified as a shiftRegister object.
value
— Data to write
numeric | character vector of '1'
or '0'
| vector of 1 or 0
Data to write to the data pin of a SIPO
shift register. Specify the data either as a number or as a character vector of
'1'
or '0'
or as a vector of 1 or 0, or as a
hexadecimal or binary.
Note
If you specify the data as a number, the value must be within the range of precision.
If you specify the data as a character vector of
'1'
or'0'
, the length of the vector must match with precision and the vector must start with the most significant bit or the highest bit for the shift register. For example, if you write a character vector of'00001010'
with length 8, specify the precision as'uint8'
.If you specify the data as a vector of 1 or 0, the vector must start with the least significant bit or the lowest bit for the shift register and the length of the vector must match with precision. For example, if you write a vector of
[0 0 0 0 1 0 1 0]
of length 8, specify precision as'uint8'
.
precision
— Data precision
'uint8'
(default) | 'uint16'
| 'uint32'
| 'uint64'
Data precision, specified as one of the following character vectors:
'uint8'
'uint16'
'uint32'
'uint64'
Data can be also be specified in the following formats:
hexadecimal
binary
char
string
Version History
Introduced in R2016b
See Also
arduino
| shiftRegister
| read
| reset
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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)