//-----Definicion de pines---------
const uint8_t signal_a = 2, signal_b = 3;
//---------------------------------

const int encoder_resolution = 20;
const float steps2deg = 360.0/((float)encoder_resolution);

volatile int encoder_counter = 0;

int last_count;

void encoder_interrupt(){
  bool b_state = digitalRead(signal_b);
  if(b_state){ // CCW
    encoder_counter--;
  }
  else{
    encoder_counter++;
  }
}

int encoder_steps(){
  return encoder_counter;
}

void setup() {
  Serial.begin(115200);
  pinMode(signal_a, INPUT);
  pinMode(signal_b, INPUT);

  attachInterrupt(digitalPinToInterrupt(signal_a),encoder_interrupt,FALLING);

  last_count = encoder_steps();

  control.enable(false);

  Serial.println("Ender_test");
}

void loop() {
  if(last_count != encoder_steps()){
    last_count = encoder_steps();
    Serial.print("El angulo es =");
    Serial.println(last_count * steps2deg);
  }
}