Microchip | The Embedded Control Solutions Company Register Login
Browse All
atruntime.com
 10 Code Snippets

Optical encoder code example

atruntime.com

This optical encoder (part number: 62A22-01-040S) has a 2-bit quadrature coded output. This example eliminates bounces and let you know the spin sense easily.

About this Code Example

#include "EncoderDriver.h"


void main (void)
{
   InitEncoder();

    while(1)
    {

            switch(ReadEncoder())
            {
                case '+':
                //right spin, invoked when the encoder rotates one step                           
                break;

                case '-':                      
                //left spin, invoked when the encoder rotates one step                         
                break;
            }

    }

}








Categories

Release History

  • Jan 30, 2012

    Version: 1.0.0

    first release

Download Contact the Developer

*Required Fields


  • Current Version:1.0.0
  • Created:Jan 30, 2012
  • Updated:Feb 26, 2015
  • Downloads:7290
  • MPLAB Version:8.83
  • C Compiler:C18,C30,C32
  • Development Tools:ICD3
  • Supported Devices:PIC18,PIC24,DSPIC,PIC32

Corporate News

Resources

Stay Connected

Stay up to date with the latest news from Microchip Technology.