Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Red/Green ... Rotary encoder

Status
Not open for further replies.

granddad

Well-Known Member
Most Helpful Member
Found this encoder .. looks very useful for my current project . has Bi colour led and push switch... from uk supplier hobbytronics.com ( top is extra ) drawback has no threaded collar , so board will have to be mounted ..
Think it from sparkfun
https://www.hobbytronics.co.uk/rotary-encoder-rg

greenen.jpg
 
Last edited:
A link would be nice or something like a data sheet? Things like what does it encode and what is the resolution/output?

Ron
 
I have a very similar one but without the LED. For encodeing the outputs I used a simple lookup table.
This is Arduino code. It makes a 16 bit number from the last states and the new states. Might be useful.
Code:
  const int8_t lookup_table[] = {0,-1,1,0,1,0,0,-1,-1,0,0,1,0,1,-1,0};
  rotateState<<=2;
  if(digitalRead(A0))
      rotateState+=1;
  if(digitalRead(A1))
      rotateState+=2;
  rotateState&=15;
  number+=lookup_table[rotateState];
  // keep in the range 0 to 19999
  if(number>32767)
    number=19999;
  else if(number>19999)
    number=0;

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top