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

 
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.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…