started with the 28BYJ-48 stepper motor A stepper motor, also known
as step motor or stepping motor, is a brushless DC electric motor that
divides a full rotation into a number of equal steps. The motor's
position can then be commanded to move and hold at one of these steps
without any position sensor for feedback (an open-loop controller), as
long as the motor is carefully sized to the application in respect to
torque and speed.
One round number of pulse: 20
Working voltage: 5V The rotary encoder
can count the number of pulse output during rotation in the positive
direction and reverse direction through the rotation and this rotation
counts are not limited. With the key on the rotary encoder, you can
reset to the initial state, that is, counting from 0. The Material of
Knob Cap: aluminium alloy The Specification of Knob Cap: diameter:
15mm/ 0.59in; height: 16.5mm/ 0.65in.
Before start working with the encoder and the Arduino board, read this
When the detectors A or B are on the top of the block, it outputs logic
HIGH pulses, otherwise it outputs LOW. If the rotor moves clock-wise,
then before A changes its state (from low to high or from high to low),
A and B are in the same state. If it rotates counter clock-wise, right
before A changes its state, A and B are in different states. We can use
this simple algorithm to code up a scirpt in Arduino to tell the
direction the rotor rotates.
Encoder Arduino Example:
Make the following hardware connections:
Output A - Pin 6 (Arduino)
Output B - Pin 7 (Arduino)
Button Pin - Null (Keep it float for the first example)
VCC - 5V (Arduino)
GND - GND (Arduino)
the code to your Arduino
board. Open the Serial Monitor to check the positions of the encoder.
Now, let's add the stepper motor back to the breadboard and use the
encoder to control the movement of the stepper motor precisely.
The code is not provided here but you should be able to make your own
based on the code provided in the first two examples.