Rotary encoder + 7 segment display.

We have warned you before that we cannot help fix your code unless you post the whole code.

But.. In my post 17 is all code which I have? :wink:

I have nothing more, because I cant write code which will have actual value of encoder. This option:
"( encoder.count ==> after updateEncoders(); this int will contain the current count value )"

wont work for me.

Again. The same code as is in 17 post:

// rotary encoder demo by 'jurs' for Arduino Forum
// This is the code for the main "sketch"

#include "encoder.h"
#define BAUDRATE 115200L // serial baud rate
#define LEDPin 12 //up

void setup() {
  Serial.begin(BAUDRATE);
  Serial.println();
  Serial.println("Good night and good luck!"); // print some Test-Message at beginning
  beginEncoders();
  pinMode(LEDPin, OUTPUT);
}


void printEncoders()
{ // print current count of each encoder to Serial
  for (int i=0; i<NUMENCODERS; i++)
  {
    Serial.print(encoder[i].count);
    Serial.print('\t');
  }
  Serial.println();
}

void loop() {
  if (updateEncoders()) printEncoders();
  


}

and encoder.h

// rotary encoder include file by 'jurs' for Arduino Forum
// This is the code for a new "Tab" within the sketch with Tab name "encoder.h"
#include <Arduino.h>
struct rotary_t {byte pinA; byte pinB; int count;};

rotary_t encoder[]={
 {A4,A5}, 
};  

#define NUMENCODERS (sizeof(encoder)/sizeof(encoder[0]))

volatile byte state_ISR[NUMENCODERS];
volatile int8_t count_ISR[NUMENCODERS];

void startTimer2()  // start TIMER2 interrupts
{
  noInterrupts();
  // Timer 2 CTC mode
  TCCR2B = (1<<WGM22) | (1<<CS22)  | (1<<CS20);
  TCCR2A = (1<<WGM21);
  OCR2A = 124;   // 249==500,  124==1000 interrupts per second
                 // 63 ==2000,  31==4000
                 // 15 ==8000,   7==16000
  TIMSK2 = (1<<OCIE2A); // enable Timer 2 interrupts
  interrupts();
}

void stopTimer2() // stop TIMER2 interrupts
{
  noInterrupts();
  TIMSK2 = 0;
  interrupts();
}

int8_t readEncoder(byte i)
{ // this function is called within timer interrupt to read one encoder!
  int8_t result=0;
  byte state=state_ISR[i];
  state= state<<2 | (byte)digitalRead(encoder[i].pinA)<<1 | (byte)digitalRead(encoder[i].pinB); 
  state= state & 0xF;   // keep only the lower 4 bits
  /* // next two lines would be code to read 'quarter steps'
  if (state==0b0001 || state==0b0111 || state==0b1110 || state==0b1000) result= -1;
  else if (state==0b0010 || state==0b1011 || state==0b1101 || state==0b0100) result= 1;
  */
  // next two lines is code to read 'full steps'
  if (state==0b0001) result= -1;
  else if (state==0b0010) result= 1;
  state_ISR[i]= state;
  return result;
}

void beginEncoders()
{ // active internal pullup resistors on each encoder pin and start timer2
  for (int i=0; i<NUMENCODERS; i=63)
  {
    pinMode(encoder[i].pinA, INPUT_PULLUP);
    pinMode(encoder[i].pinB, INPUT_PULLUP);
    readEncoder(i); // Initialize start condition
  }
  startTimer2();
}

boolean updateEncoders()
{ // read all the 'volatile' ISR variables and copy them into normal variables
  boolean changeState=false;
  for (int i=0; i<NUMENCODERS; i++)
  {
    if (count_ISR[i]!=0)
    {
      changeState=true;
      noInterrupts();
      encoder[i].count = constrain(encoder[i].count + count_ISR[i], 0, 63);
      count_ISR[i]=0;
      interrupts();



    }
  }
  return changeState;
}


ISR(TIMER2_COMPA_vect)  // handling of TIMER2 interrupts
{
  for (int i=0; i<NUMENCODERS; i++) 
  {
    count_ISR[i]+= readEncoder(i); 
  }
}

7 segment display code isnt needed now.

And In void loop for test I have write this:

if (encoder[i].count = 1)
{
digitalWrite(LEDPin, HIGH)
}

all code + this small fix:

// rotary encoder demo by 'jurs' for Arduino Forum
// This is the code for the main "sketch"

#include "encoder.h"
#define BAUDRATE 115200L // serial baud rate
#define LEDPin 12 //up

void setup() {
  Serial.begin(BAUDRATE);
  Serial.println();
  Serial.println("Good night and good luck!"); // print some Test-Message at beginning
  beginEncoders();
  pinMode(LEDPin, OUTPUT);
}


void printEncoders()
{ // print current count of each encoder to Serial
  for (int i=0; i<NUMENCODERS; i++)
  {
    Serial.print(encoder[i].count);
    Serial.print('\t');
  }
  Serial.println();
}

void loop() {
  if (updateEncoders()) printEncoders();
  
if (encoder[i].count = 1)
{
digitalWrite(LEDPin, HIGH)
}

}

and now I have error:

"'i' was not declared in this scope"

encoder.zip (1.8 KB)

The variable "i" had not been declared here. You can't just copy & paste lines of code and expect them to work. Each line of code is written for a particular context and won't necessarily make sense elsewhere without alteration. Try this:

if (encoder[1].count = 1)

The code you copied was written to be able to deal with multiple encoders. The line you copied was originally inside a for loop:

  for (int i=0; i<NUMENCODERS; i++)
    {
     ...
     }

That for() loop provided the variable "i". When you pasted that line into loop(), there was no "i" so the line made no sense.

You really need to brush up on your basic coding skills!

I know this that Im very bad in coding :slight_smile:

I have added this:

void loop()
{

  
   if (encoder[1].count = 1)
    {
     digitalWrite(LEDPin, HIGH);
    }

   if (encoder[1].count = 0)
    {
     digitalWrite(LEDPin, LOW);
    }


   if (updateEncoders()) printEncoders();

}

But LED is only turn on after start program. Changing values by encoder to 0,1,0,1 nothing change in LED status.

encoder.zip (1.83 KB)

   if (encoder[1].count = 1)

Comparison is == not =.

I have tested with = and ==. But it nothing changes.

With ==

void loop()
{

  
   if (encoder[1].count == 1)
    {
     digitalWrite(LEDPin, HIGH);
    }

   if (encoder[1].count == 0)
    {
     digitalWrite(LEDPin, LOW);
    }


   if (updateEncoders()) printEncoders();

}

The same. LED is always ON.

("+" LED is connected by 220R to 5VCC, "-" to 12 pin.)

Fixed

void loop()
{

  
   if (encoder[0].count == 1)
    {
     digitalWrite(LEDPin, HIGH);
    }

   if (encoder[0].count == 0)
    {
     digitalWrite(LEDPin, LOW);
    }


   if (updateEncoders()) printEncoders();

}

First encoder is "0", not "1".

gavron04:
I have tested with = and ==. But it nothing changes.

Well, you can try to eat with a fork or a pencil. But if you are trying to eat water, neither will work. That doesn't mean that when you realize you need to eat food, a pencil will work.

Hi. I have problem when I would like to add remotely contrl (IR).

"libraries\Arduino-IRremote-master\IRremote.cpp.o (symbol from plugin): In function `MATCH(int, int)':

(.text+0x0): multiple definition of `__vector_7'

sketch\encoder.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here

collect2.exe: error: ld returned 1 exit status

exit status 1"

#include <IRremote.h>

#define irPin 8  // pin dla TSOP
IRrecv irrecv(irPin);
decode_results results;

#include "encoder.h"
#define BAUDRATE 115200L // serial baud rate
#define LEDPin 12 //up




void setup()
{
  irrecv.enableIRIn();
  
  Serial.begin(BAUDRATE);
  Serial.println();
  Serial.println("Good night and good luck!"); // print some Test-Message at beginning
  beginEncoders();
  
  pinMode(LEDPin, OUTPUT);
}


void printEncoders()
{ 
  // print current count of each encoder to Serial
  for (int i=0; i<NUMENCODERS; i++)
    {
    Serial.print(encoder[i].count);
    Serial.print('\t');
    }
  Serial.println();
}

void loop()
{


  
   if (encoder[0].count = 1)
    {
     digitalWrite(LEDPin, HIGH);
    }

   if (encoder[0].count = 0)
    {
     digitalWrite(LEDPin, LOW);
    }


     if (irrecv.decode(&results))
  {
    switch (results.value)
       {
        
       }
       
   irrecv.resume();
  }
  

if (updateEncoders()) printEncoders();
}

There is problem with irromote.h <> encoder.cpp/encoder.h?

encoder ir.zip (2.14 KB)

I think that both library (encoder and IRremote) are using the same TIMER. Right?

It is possible to changed in encoder to other TIMER? Or I should use other library for encoder?

Regards

It does sound like the two libraries might be incompatible. Try other libraries if you can find them.

gavron04:
I think that both library (encoder and IRremote) are using the same TIMER. Right?

It is possible to changed in encoder to other TIMER? Or I should use other library for encoder?

Regards

If you go deeper into the documentation of both libraries, you might be able to assign a different timer. Some libraries have a facility to do that.

Hi all.

In encoder I havent found option to use other timer.

In IRremote (.cpp/.h) also I havent found option to use other timer. Only in .cpp I found this:

" Modified by Paul Stoffregen paul@pjrc.com to support other boards and timers"

But I dont know in which line I must change something to use other timer than encoder.

Ok. I found in encoder, I should change some values, maybe I will fix it.

EDIT:

Original encoder:

void startTimer2()  // start TIMER2 interrupts
{
  noInterrupts();
  // Timer 2 CTC mode
  TCCR2B = (1<<WGM22) | (1<<CS22)  | (1<<CS20);
  TCCR2A = (1<<WGM21);
  OCR2A = 124;   // 249==500,  124==1000 interrupts per second
                 // 63 ==2000,  31==4000
                 // 15 ==8000,   7==16000
  TIMSK2 = (1<<OCIE2A); // enable Timer 2 interrupts
  interrupts();
}

void stopTimer2() // stop TIMER2 interrupts
{
  noInterrupts();
  TIMSK2 = 0;
  interrupts();
}

after fix:

// rotary encoder include file by 'jurs' for Arduino Forum
// This is the code for a new "Tab" within the sketch with Tab name "encoder.h"
#include <Arduino.h>
struct rotary_t {byte pinA; byte pinB; int count;};

rotary_t encoder[]={
 {A4,A5}, 
};  

#define NUMENCODERS (sizeof(encoder)/sizeof(encoder[0]))

volatile byte state_ISR[NUMENCODERS];
volatile int8_t count_ISR[NUMENCODERS];

void startTimer1()  // start TIMER1 interrupts
{
  noInterrupts();
  // Timer 2 CTC mode
  TCCR1B = (1<<WGM12) | (1<<CS11)  | (1<<CS10);
  TCCR1A = (1<<WGM13);
  OCR1A = 124;   // 249==500,  124==1000 interrupts per second
                 // 63 ==2000,  31==4000
                 // 15 ==8000,   7==16000
  TIMSK1 = (1<<OCIE1A); // enable Timer 2 interrupts
  interrupts();
}

void stopTimer1() // stop TIMER1 interrupts
{
  noInterrupts();
  TIMSK1 = 0;
  interrupts();
}


int8_t readEncoder(byte i)
{ // this function is called within timer interrupt to read one encoder!
  int8_t result=0;
  byte state=state_ISR[i];
  state= state<<2 | (byte)digitalRead(encoder[i].pinA)<<1 | (byte)digitalRead(encoder[i].pinB); 
  state= state & 0xF;   // keep only the lower 4 bits
  /* // next two lines would be code to read 'quarter steps'
  if (state==0b0001 || state==0b0111 || state==0b1110 || state==0b1000) result= -1;
  else if (state==0b0010 || state==0b1011 || state==0b1101 || state==0b0100) result= 1;
  */
  // next two lines is code to read 'full steps'
  if (state==0b0001) result= -1;
  else if (state==0b0010) result= 1;
  state_ISR[i]= state;
  return result;
}

void beginEncoders()
{ // active internal pullup resistors on each encoder pin and start timer2
  for (int i=0; i<NUMENCODERS; i=63)
  {
    pinMode(encoder[i].pinA, INPUT_PULLUP);
    pinMode(encoder[i].pinB, INPUT_PULLUP);
    readEncoder(i); // Initialize start condition
  }
  startTimer1();
}

boolean updateEncoders()
{ // read all the 'volatile' ISR variables and copy them into normal variables
  boolean changeState=false;
  for (int i=0; i<NUMENCODERS; i++)
  {
    if (count_ISR[i]!=0)
    {
      changeState=true;
      noInterrupts();
      encoder[i].count = constrain(encoder[i].count + count_ISR[i], 0, 63);
      count_ISR[i]=0;
      interrupts();



    }
  }
  return changeState;
}


ISR(TIMER1_COMPA_vect)  // handling of TIMER2 interrupts
{
  for (int i=0; i<NUMENCODERS; i++) 
  {
    count_ISR[i]+= readEncoder(i); 
  }
}

Now work :slight_smile: But only count 0<>1 :frowning:

Ok. Now work ok.

// rotary encoder include file by 'jurs' for Arduino Forum
// This is the code for a new "Tab" within the sketch with Tab name "encoder.h"
#include <Arduino.h>
struct rotary_t {byte pinA; byte pinB; int count;};

rotary_t encoder[]={
 {A4,A5}, 
};  

#define NUMENCODERS (sizeof(encoder)/sizeof(encoder[0]))

volatile byte state_ISR[NUMENCODERS];
volatile int8_t count_ISR[NUMENCODERS];

void startTimer1()  // start TIMER1 interrupts
{
  noInterrupts();
  // Timer 2 CTC mode
  TCCR1B = (1<<WGM12) | (1<<CS12)  | (1<<CS10);
  TCCR1A = (1<<WGM13);
  OCR1A = 31;   // 249==500,  124==1000 interrupts per second
                 // 63 ==2000,  31==4000
                 // 15 ==8000,   7==16000
  TIMSK1 = (1<<OCIE1A); // enable Timer 2 interrupts
  interrupts();
}

void stopTimer1() // stop TIMER1 interrupts
{
  noInterrupts();
  TIMSK1 = 0;
  interrupts();
}


int8_t readEncoder(byte i)
{ // this function is called within timer interrupt to read one encoder!
  int8_t result=0;
  byte state=state_ISR[i];
  state= state<<2 | (byte)digitalRead(encoder[i].pinA)<<1 | (byte)digitalRead(encoder[i].pinB); 
  state= state & 0xF;   // keep only the lower 4 bits
  /* // next two lines would be code to read 'quarter steps'
  if (state==0b0001 || state==0b0111 || state==0b1110 || state==0b1000) result= -1;
  else if (state==0b0010 || state==0b1011 || state==0b1101 || state==0b0100) result= 1;
  */
  // next two lines is code to read 'full steps'
  if (state==0b0001) result= -1;
  else if (state==0b0010) result= 1;
  state_ISR[i]= state;
  return result;
}

void beginEncoders()
{ // active internal pullup resistors on each encoder pin and start timer2
  for (int i=0; i<NUMENCODERS; i=63)
  {
    pinMode(encoder[i].pinA, INPUT_PULLUP);
    pinMode(encoder[i].pinB, INPUT_PULLUP);
    readEncoder(i); // Initialize start condition
  }
  startTimer1();
}

boolean updateEncoders()
{ // read all the 'volatile' ISR variables and copy them into normal variables
  boolean changeState=false;
  for (int i=0; i<NUMENCODERS; i++)
  {
    if (count_ISR[i]!=0)
    {
      changeState=true;
      noInterrupts();
      encoder[i].count = constrain(encoder[i].count + count_ISR[i], 0, 63);
      count_ISR[i]=0;
      interrupts();



    }
  }
  return changeState;
}


ISR(TIMER1_COMPA_vect)  // handling of TIMER2 interrupts
{
  for (int i=0; i<NUMENCODERS; i++) 
  {
    count_ISR[i]+= readEncoder(i); 
  }
}

I would like to add "+1" or "-1" by pressing vol+/vol- on remote control.

but how to add this "+1"/"-1" to encoder[0].count?

Now I have added VOL+ and VOL-. Adding is good, but it doesnt work correctly. Sometimes when I click "VOL+" on remote I have added 2-3, not 1,1,1,1,1,1.

// rotary encoder demo by 'jurs' for Arduino Forum
// This is the code for the main "sketch"

#include <IRremote.h>

#define irPin 8  // pin dla TSOP
IRrecv irrecv(irPin);
decode_results results;


#include "encoder.h"
#define BAUDRATE 115200L // serial baud rate
#define LEDPin 12 //up

void setup() {

   irrecv.enableIRIn();
   
  Serial.begin(BAUDRATE);
  Serial.println();
  Serial.println("Good night and good luck!"); // print some Test-Message at beginning
  beginEncoders();
  pinMode(LEDPin, OUTPUT);
}

void printEncoders()
{ // print current count of each encoder to Serial
  for (int i=0; i<NUMENCODERS; i++)
  {
    Serial.print(encoder[i].count);
    Serial.print('\t');
  }
  Serial.println();
}


void loop()
{

  
   if (encoder[0].count == 1)
    {
     digitalWrite(LEDPin, HIGH);
    }

   if (encoder[0].count == 0)
    {
     digitalWrite(LEDPin, LOW);
    }





     if (irrecv.decode(&results))
  {
    switch (results.value)
       {
         case 0x801:  // 1
            digitalWrite(LEDPin, LOW);
            break;
          case 0x1:  // 1
            digitalWrite(LEDPin, HIGH);
            break;
         case 0x810:  // VOL+
            encoder[0].count ++;
            break;
          case 0x10:  // VOL+
            encoder[0].count ++;
            break;

          case 0x811:  // VOL-
            encoder[0].count --;
            break;
          case 0x11:  // VOL-
            encoder[0].count --;
            break;
       }
       
   irrecv.resume();
  }
   if (updateEncoders()) printEncoders();
}

I have question. How can I update in serial monitor count when I press VOL+/VOL-? It doesnt count when I press VOL+/- , I must turn encoder to update status in serial monitor.

Hi all.

There is possible to drive pin 10 (SS) as normal OUTPUT? I have problem with drive 7 segment with SevSeg library, on pin SS I have segment "A" and it was allways ON. I think that there is a problem with timer in encoder library.

With IR library (without encoder library) all works ok with segment "A" on pin SS

With IR library and with enocoder library segment "A" is always ON (on pin SS). On pin SS I have 2,20VDC always..

After changed segment "A" to other pin all is ok.

There is possible to fix it and make something that on SS pin segment "A" will work properly? Or I must use other pin?

Encoder.h

// rotary encoder include file by 'jurs' for Arduino Forum
// This is the code for a new "Tab" within the sketch with Tab name "encoder.h"
#include <Arduino.h>
struct rotary_t {byte pinA; byte pinB; int count;};

rotary_t encoder[]={
 {5,7}, 
};  

#define NUMENCODERS (sizeof(encoder)/sizeof(encoder[0]))

volatile byte state_ISR[NUMENCODERS];
volatile int8_t count_ISR[NUMENCODERS];

void startTimer1()  // start TIMER1 interrupts
{
  noInterrupts();
  // Timer 2 CTC mode
  TCCR1B = (1<<WGM12) | (1<<CS12)  | (1<<CS10);
  TCCR1A = (1<<WGM13);
  OCR1A = 124;   // 249==500,  124==1000 interrupts per second
                 // 63 ==2000,  31==4000
                 // 15 ==8000,   7==16000
  TIMSK1 = (1<<OCIE1A); // enable Timer 2 interrupts
  interrupts();
}

void stopTimer1() // stop TIMER1 interrupts
{
  noInterrupts();
  TIMSK1 = 0;
  interrupts();
}


int8_t readEncoder(byte i)
{ // this function is called within timer interrupt to read one encoder!
  int8_t result=0;
  byte state=state_ISR[i];
  state= state<<2 | (byte)digitalRead(encoder[i].pinA)<<1 | (byte)digitalRead(encoder[i].pinB); 
  state= state & 0xF;   // keep only the lower 4 bits
  /* // next two lines would be code to read 'quarter steps'
  if (state==0b0001 || state==0b0111 || state==0b1110 || state==0b1000) result= -1;
  else if (state==0b0010 || state==0b1011 || state==0b1101 || state==0b0100) result= 1;
  */
  // next two lines is code to read 'full steps'
  if (state==0b0001) result= -1;
  else if (state==0b0010) result= 1;
  state_ISR[i]= state;
  return result;
}

void beginEncoders()
{ // active internal pullup resistors on each encoder pin and start timer2
  for (int i=0; i<NUMENCODERS; i=63)
  {
    pinMode(encoder[i].pinA, INPUT_PULLUP);
    pinMode(encoder[i].pinB, INPUT_PULLUP);
    readEncoder(i); // Initialize start condition
  }
  startTimer1();
}

boolean updateEncoders()
{ // read all the 'volatile' ISR variables and copy them into normal variables
  boolean changeState=false;
  for (int i=0; i<NUMENCODERS; i++)
  {
    if (count_ISR[i]!=0)
    {
      changeState=true;
      noInterrupts();
      encoder[i].count = constrain(encoder[i].count + count_ISR[i], 0, 63);
      count_ISR[i]=0;
      interrupts();



    }
  }
  return changeState;
}


ISR(TIMER1_COMPA_vect)  // handling of TIMER2 interrupts
{
  for (int i=0; i<NUMENCODERS; i++) 
  {
    count_ISR[i]+= readEncoder(i); 
  }
}
// rotary encoder include file by 'jurs' for Arduino Forum
// This is the code for a new "Tab" within the sketch with Tab name "encoder.h"
#include <Arduino.h>
struct rotary_t {byte pinA; byte pinB; int count;};

rotary_t encoder[]={
 {5,7}, 
};  

#define NUMENCODERS (sizeof(encoder)/sizeof(encoder[0]))

volatile byte state_ISR[NUMENCODERS];
volatile int8_t count_ISR[NUMENCODERS];

void startTimer1()  // start TIMER1 interrupts
{
  noInterrupts();
  // Timer 2 CTC mode
  TCCR1B = (1<<WGM12) | (1<<CS12)  | (1<<CS10);
  TCCR1A = (1<<WGM13);
  OCR1A = 124;   // 249==500,  124==1000 interrupts per second
                 // 63 ==2000,  31==4000
                 // 15 ==8000,   7==16000
  TIMSK1 = (1<<OCIE1A); // enable Timer 2 interrupts
  interrupts();
}

void stopTimer1() // stop TIMER1 interrupts
{
  noInterrupts();
  TIMSK1 = 0;
  interrupts();
}


int8_t readEncoder(byte i)
{ // this function is called within timer interrupt to read one encoder!
  int8_t result=0;
  byte state=state_ISR[i];
  state= state<<2 | (byte)digitalRead(encoder[i].pinA)<<1 | (byte)digitalRead(encoder[i].pinB); 
  state= state & 0xF;   // keep only the lower 4 bits
  /* // next two lines would be code to read 'quarter steps'
  if (state==0b0001 || state==0b0111 || state==0b1110 || state==0b1000) result= -1;
  else if (state==0b0010 || state==0b1011 || state==0b1101 || state==0b0100) result= 1;
  */
  // next two lines is code to read 'full steps'
  if (state==0b0001) result= -1;
  else if (state==0b0010) result= 1;
  state_ISR[i]= state;
  return result;
}

void beginEncoders()
{ // active internal pullup resistors on each encoder pin and start timer2
  for (int i=0; i<NUMENCODERS; i=63)
  {
    pinMode(encoder[i].pinA, INPUT_PULLUP);
    pinMode(encoder[i].pinB, INPUT_PULLUP);
    readEncoder(i); // Initialize start condition
  }
  startTimer1();
}

boolean updateEncoders()
{ // read all the 'volatile' ISR variables and copy them into normal variables
  boolean changeState=false;
  for (int i=0; i<NUMENCODERS; i++)
  {
    if (count_ISR[i]!=0)
    {
      changeState=true;
      noInterrupts();
      encoder[i].count = constrain(encoder[i].count + count_ISR[i], 0, 63);
      count_ISR[i]=0;
      interrupts();



    }
  }
  return changeState;
}


ISR(TIMER1_COMPA_vect)  // handling of TIMER2 interrupts
{
  for (int i=0; i<NUMENCODERS; i++) 
  {
    count_ISR[i]+= readEncoder(i); 
  }
}

How Can I set first value to 63, not 0? (Now, after power reset I have value "0". I would like to get "63").

I have changed:

      encoder[i].count = constrain(encoder[i].count + count_ISR[i], 0, 63);

from 0,63 to 63,0 but it doesnt work.

void beginEncoders()
{ // active internal pullup resistors on each encoder pin and start timer2
  for (int i=0; i<NUMENCODERS; i++)
  {
    pinMode(encoder[i].pinA, INPUT_PULLUP);
    pinMode(encoder[i].pinB, INPUT_PULLUP);
    encoder[i].count = 63;
    readEncoder(i); // Initialize start condition
  }
  startTimer1();
}
1 Like