Using a rotary encoder with AVR Micro controller

后端 未结 5 1209
小鲜肉
小鲜肉 2021-02-10 06:48

I\'m having trouble getting a rotary encoder to work properly with AVR micro controllers. The encoder is a mechanical ALPS encoder, and I\'m using Atmega168.

Cla

5条回答
  •  长发绾君心
    2021-02-10 07:10

    /* into 0 service rutine */
    if(CHB)
    {
      if(flagB)
       Count++;
      FlagB=0;
    }
    else
    {
      if(FlagB)
       count--:
      FlagB=0:
    }
    
    /* into 1 service rutine */
    FlagB=1;
    
    /* make this give to you a windows time of 1/4 of T of the encoder resolution
       that is in angle term: 360/ (4*resolution)
     */
    

提交回复
热议问题