New approach to Rotary Encoder


Results 1 to 40 of 91

Threaded View

  1. #33
    Join Date
    Sep 2009
    Posts
    23


    Did you find this post helpful? Yes | No

    Default Re: New approach to Rotary Encoder

    My own code for reading Rotary Encoder




    Code:
    '****************************************************************
    '*  Name    : UNTITLED.BAS                                      *
    '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
    '*  Notice  : Copyright (c) 2013 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 16/2/2013                                         *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    TRISA  = %11111    '
    TRISB  = %00000000 '8 LEDs.
    
    PORTB=0            '
    
    x    VAR   Byte  '
    Aux  VAR   Byte  ' 
    Enc  VAR   Byte  '
    
    
    
    x=0                ' 
    Aux=0              
    Enc=0              
    
    
    aaa:                    
        Aux = Enc                         '               
         Enc = (PORTA & 3)                 ' RA0  RA1 2 bits variable 'ENC'.
         If Aux = 2 And Enc = 3 Then x=x+1 ' 
         If Aux = 3 And Enc = 2 Then x=x-1 ' 
         PORTB =  x                         ' 8 LED 
         
        goto aaa
    
    End
    Attached Images Attached Images  

Members who have read this thread : 4

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts