Monday 22 January 2018

Rotary Encoder – How to Use it?

Introduction:

A Rotary Encoder is an Electromechanical device which detects the Angular movement of shaft and convert it to provide Analog or Digital output. The encoder has a disk with evenly spaced contact zones that are connected to the common pin and two other separate contact pins.
When the disc starts to rotate step by step, both pins start making contact with the common pin and thus produce a sqaure wave in the output.
Unlike a variable resistor/potentiometer rotary encoder has infinite direction of movement. As they produce digital Gray Code, so we get an advantage of scaling their readings to whatever range we like.                                                   The dual direction movement makes them useful to increase and decrease the value within the same variable.
It has inbuilt switch which makes it compatible to use wherever toggling is required.

Usage:

Rotary Encoders have wide variety of applications, such as:
Rotating servo motors, Linear Measurement, Backstop Gauging and various industries like: Material Handling, Packaging, Mobile Equipment, Textile etc.

Applications:

Project for Reference:


Code:
#include <RotaryEncoder.h>

// Setup a RoraryEncoder for pins A2 and A3:
RotaryEncoder encoder(A2, A3);

void setup()
{
  Serial.begin(57600);
  Serial.println("SimplePollRotator example for the RotaryEncoder library.");
} // setup()


// Read the current position of the encoder and print out when changed.
void loop()
{
  static int pos = 0;
  encoder.tick();

  int newPos = encoder.getPosition();
  if (pos != newPos) {
    Serial.print(newPos);
    Serial.println();
    pos = newPos;
  } // if

No comments:

Post a Comment

SMART BLIND STICK The smart blind stick is the project made to help the blind people who is suffering when walking.It just uses to de...