Intro: Tutorial for Arduino 360 Degree Encoder
A rotary encoder is an incremental electromechanical component with a shaft that converts the angular position or motion of a shaft or axle to digital code. The output of incremental encoders provides information about the motion of the shaft, which is typically further processed in processor / controllers into information such as speed, distance, and position.The shaft has unlimited 360 degree rotation.
- Model: SN-360
- Type: Incremental Encoder
- Cycles per revolution (CPR): 20
- Working voltage: 0 – 5V
- Material: PCB + Brass
- Weight: 10g
- Size: 32 x 19 x 30mm
Step 1: Material Preparation
To do this tutorial, you will need as following below:
1. Arduino 360 Degree Encoder
2. Arduino Uno Board and USB Cable
3. Female-Male Jumper Wires
Step 2: Pinout Details
- CLK : Pin A
- DT : Pin B
- S : No push switch connection
- + : Power
- GND : Grounding
Step 3: Pin Connection
Connect Arduino 360 Degree Encoder to Arduino Uno as following :
- VCC to 5V
- GND to GND
- CLK to D3
- CLK to D4
and then connect Arduino Uno to your PC.
Step 4: Sample Source Code
This is a sample source code for the circuit. You can download, open and and upload it into your Arduino Uno Board. Make sure to go to tools > Port & Board. Select the correct board (Arduino/Genuino Uno) and port (refer to your own port COM#) before uploading the code.
Step 5: Serial Monitor
After you have succesfully uploaded it into you Arduino Uno Board. Go to tools > Serial Monitor and you will see "BEGIN" printed on the serial monitor. Now, you can start to rotate your encoder's shaft and see the output printed on the serial monitor.
Step 6: Result
- When you rotate the shaft clockwise, serial monitor will print
Encoder Count: 1
Encoder Count: 2
- and when you rotate clockwise, serial monitor will print
Encoder Count: 0
Encoder Count: -1
- You can feel a small “clicks” as you turn the encoder.