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

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

Multimeter probes - needle tips

Multimeter probes - needle tips

Multimeter probes - needle tip black and red Sharp and hard stainless steel needle test leads 4 DMM multimeter CE CATII 600V MAX. 1A 4mm socket A820155 These needle tipped multimeter probes are..

R25.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

Jack 3.5mm 4 Pin Male (4 Pack)

Jack 3.5mm 4 Pin Male (4 Pack)

Jack 3.5mm 4 Pin Male (4 Pack) If your looking to have not only audio, but microphone capabilities via aux, these audio jacks will do the job. These audio jacks are general unbalanced TRRS jacks, whi..

R25.00

Voltage Regulator 3.3V (Pack of 2)

Voltage Regulator 3.3V (Pack of 2)

LD1117  Voltage Regulator 3.3V (Pack of 2) This is the basic LD33cv voltage regulator, a low drop positive regulator with a 3.3V fixed output voltage. This fixed regulator provides a grea..

R12.00