Lesson 43--Microduino Rotary encoder

From Microduino Wiki
Revision as of 08:59, 12 September 2016 by Fengfeng (talk)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Language: English  • 中文

Objective

This experiment will through Microduino to decode the rotary encoder, judge the movement direction and whether it was pressed.

Equipment

Rotary encoder

Rotary encoder

Rotary encoder.jpg

This kind of rotary encoder has turn left, turn right and press three functions. The function of the press just like we use the button. Rotate the encoder, it caan produce the pulse signal that has a different phase, which can be used to distinguish the opposite direction.

Rotary encoder Signal.jpg

If the output 1 as the high electricity level, and a high level in output 2 too, then switch rotated as clockwise, otherwise output 2 is a low level, it must be counterclockwise.

Pin Diagram

Rotary encoder pin.jpg

Schematic

Rotary encoder Wiring.jpg

Program

Download test program: https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Advanced/Microduino_rotary_encoder

Debug

  • Step 1:

Set up the circuit follow the schematic

Rotary encoder Wiring-1.jpg
  • Step 2: Download test program
  • Step 3: Open the test program, select the board and compile the program, then download it.
  • Configure the serial baud rate and open the serial monitor
  • Rotate and press the button, observe the date
    • Clockwise rotation
Rotary encoder Clockwise.jpg
    • Counterclockwise rotation
Rotary encoder Counterclockwise.jpg
    • Press the button
Rotary encoder button.jpg

Result

According to the serial port monitor returned data to judge the state of rotary encoder. The players can make other application based on this experiment.

Video