EC11 Rotary Encoder

  • Brand: Generic
  • Product Code: EC11-VER-15-SP
  • Stock

    Warehouse Stock Status Location
    Centurion In Stock X326
    Stellenbosch In Stock Z5121
  • R14.85 (price excl. VAT)


Rotary Encoder

A rotary or "shaft" encoder is an angular measuring device. It is used to precisely measure rotation of motors or to create wheel controllers (knobs) that can turn infinitely (with no end stop like a potentiometer has). Some of them are also equipped with a pushbutton when you press on the axis (like the ones used for navigation on many music controllers). 

Quick Spec

  • Click Positions : 20 
  • Shaft Length : 15mm
  • Rotation : 360 Degree
  • Mount: Vertical PCB
  • Built in Push Button : Yes
  • Shaft: Round with Flat edge

Code Example

// Rotary encoder example.
// Author: Nick Gammon
// Date:   24th May 2011

// Wiring: Connect common pin of encoder to ground.
// Connect pins A and B (the outer ones) to pins 2 and 3 (which can generate interrupts)

volatile boolean fired = false;
volatile long rotaryCount = 0;

// Interrupt Service Routine
void isr ()
{
  
static boolean ready;
static unsigned long lastFiredTime;
static byte pinA, pinB;  

// wait for main program to process it
  if (fired)
    return;
    
  byte newPinA = digitalRead (2);
  byte newPinB = digitalRead (3);
  
  // Forward is: LH/HH or HL/LL
  // Reverse is: HL/HH or LH/LL
  
  // so we only record a turn on both the same (HH or LL)
  
  if (newPinA == newPinB)
    {
    if (ready)
      {
      long increment = 1;
        
      // if they turn the encoder faster, make the count go up more
      // (use for humans, not for measuring ticks on a machine)
      unsigned long now = millis ();
      unsigned long interval = now - lastFiredTime;
      lastFiredTime = now;
      
      if (interval < 10)
        increment = 5;
      else if (interval < 20)
        increment = 3;
      else if (interval < 50)
        increment = 2;
         
      if (newPinA == HIGH)  // must be HH now
        {
        if (pinA == LOW)
          rotaryCount += increment;
        else
          rotaryCount -= increment;
        }
      else
        {                  // must be LL now
        if (pinA == LOW)  
          rotaryCount -= increment;
        else
          rotaryCount += increment;        
        }
      fired = true;
      ready = false;
      }  // end of being ready
    }  // end of completed click
  else
    ready = true;
    
  pinA = newPinA;
  pinB = newPinB;
}  // end of isr


void setup ()
{
  digitalWrite (2, HIGH);   // activate pull-up resistors
  digitalWrite (3, HIGH); 
  
  attachInterrupt (0, isr, CHANGE);   // pin 2
  attachInterrupt (1, isr, CHANGE);   // pin 3

  Serial.begin (115200);
}  // end of setup

void loop ()
{

  if (fired)
    {
    Serial.print ("Count = ");  
    Serial.println (rotaryCount);
    fired = false;
  }  // end if fired

}  // end of loop

read more here

Shipping List

  • 1 X EC11 Rotary Encoder


Related Products

Rotary Encoder - Breadboard Ready

Rotary Encoder - Breadboard Ready

Rotary Encoder - Breadboard Ready The KY-040 rotary encoder is a rotary input device (as in knob) that provides an indication of how much the knob has been rotated AND what direction it is rotating i..

R20.00

Tags: rotary encoder, ec11, rotary, encoder, shaft encoder, 15mm

Also Bought

Tactile Switch 4 Pin H=5mm TH (10 pack)

Tactile Switch 4 Pin H=5mm TH (10 pack)

Tactile Switch 4 Pin H=5mm TH (10 pack) Tactile switches are small compact micro switches. They are very useful when you need a small button button in your project. The switches are momentary NO (Nor..

R10.00

Alu Knob 20 X 16mm 6mm Shaft

Alu Knob 20 X 16mm 6mm Shaft

Alu Knob 20 X 16mm 6mm Shaft These aluminum knobs are for are great for rotary potentiometers, for protection, easy control and giving your projects a sleek and clean finish. Quick Spec Mat..

R25.00

MPU6050 Triple Axis Accelerometer + Gyro 6DOF

MPU6050 Triple Axis Accelerometer + Gyro 6DOF

MPU6050 3-Axis Acceleration + Gyroscope 6DOF - I2C Interface The MPU6050 contains both a 3-Axis Gyroscope and a 3-Axis accelerometer allowing measurements of both independently, but all based around ..

R89.00

NE555 + CD4017 Running Light Kit

NE555 + CD4017 Running Light Kit

NE555 + CD4017 Running Light Kit The kits' main circuit and decimal counter circuit is generated by the clock, by the NE555 as the core of self-excited multi-vibrator power through R2, R3, R4 to char..

R20.00

2.0" 320x240 Colour IPS TFT Display

2.0" 320x240 Colour IPS TFT Display

2.0" 320x240 Colour IPS TFT Display This IPS display breakout is the best way to add a small, colorful and bright display to any project, with excellent visibility from any angle. Since the display u..

R385.00