Skip to content

Latest commit

 

History

History
46 lines (27 loc) · 891 Bytes

README.md

File metadata and controls

46 lines (27 loc) · 891 Bytes

ROTARY ENCODER LIBRARY FOR ATMEGA328P

Descripton: It is a library for rotary encoder.Of this library purpose is detect direction of encoder rotation and increase or decrease encoder rotation count. it requiers PCINT ISR for work correctly.

WARNING:

  • if you don't use PCINT ISR it doesn't reads fast rotations, especialy WITHOUT PCINT ISR it doesn't works at all if you have a big code.

  • Also pins and ports only can be changed in 'encoder.c' file by changeing values of macros.

#FUNCTIONS:

  • void encoder_rotary(void);

  • volatile int read_encoder(void);

#VARIABELS:

  • volatile static uint8_t A_state = 0;
  • volatile static uint8_t B_state = 0;
  • volatile int R_count = 0;

#CONFIGURATIONS:

  • #define MIN 0
  • #define MAX 999
  • #define PIN_A 6
  • #define PIN_B 5
  • #define PIN PIND

#LIBRARIES:

  • #include<avr/io.h>