This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

read

Read data from shift register

Syntax

out = read(register)
out = read(register,precision)

Description

example

out = read(register) reads data from the data pin of a parallel-in/serial-out (PISO) shift register.

example

out = read(register,precision) also specifies the data precision.

Examples

collapse all

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 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

collapse all

Shift register connection, specified as a shiftRegister object.

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

collapse all

Data read from the data pin of a PISO shift register, returned as a double scalar or vector.

Introduced in R2016b