Main Content

resetCount

Set count value to zero or user-specified value

Add-On Required: This feature requires the MATLAB Support Package for Arduino Hardware add-on.

Description

example

resetCount(encoder) resets the count value of the quadrature encoder to zero.

example

resetCount(encoder,count) resets the count value of the quadrature encoder to a user-specified value.

Tip

First rotate the motor to a specified starting location, then use resetCount function to set the count value to a fixed number to start from a known location.

Examples

collapse all

Create an Arduino® object with the 'rotaryEncoder' library.

a = arduino('COM4','Uno','Libraries','rotaryEncoder');

Connect to the encoder that is connected to your Arduino board.

encoder = rotaryEncoder(a,'D2','D3');

Reset encoder count value to 0.

resetCount(encoder);

Create an Arduino object with the 'rotaryEncoder' library.

a = arduino('COM4','Uno','Libraries','rotaryEncoder');

Connect to the encoder that is connected to your Arduino board.

encoder = rotaryEncoder(a,'D2','D3');

Set encoder count value to 10.

resetCount(encoder,10);

Input Arguments

collapse all

Quadrature encoder connection, specified as a rotaryEncoder object.

Encoder count value to set, specified as a number.

Version History

Introduced in R2017a