interrupts on pins 13 & 14 doens't work on teensy 3.5. + how to call 2 hat switches?
Hi,
I'm using 4 rotary encoders in my project on teensy 3.5, and i managed to get the first 2 encoders work great with interrupts. they are connected on pins 51,52,53,54.
I copied and pasted the same code to the other two encoders, but nothing happens.
I don't know how to even check if something happens with the interrupts.
Checked with a scope and the signals are working great.
i tried looking for an answer about the specific pins, but couldn't find any answer.
I know i can only use interrupt on digital pins so there shouldn't be any problem with firing the interrupts...
(just to mention - reading the pins with digitalread is working but the teensy is missing changes)
any help would be highly appreciated...
here is the code:
i would also like to know what is the correct syntax to use with more then 1 hat switch? should i declare something?
That is when using the many axis joystick code.
Thanks.
Hi,
I'm using 4 rotary encoders in my project on teensy 3.5, and i managed to get the first 2 encoders work great with interrupts. they are connected on pins 51,52,53,54.
I copied and pasted the same code to the other two encoders, but nothing happens.
I don't know how to even check if something happens with the interrupts.
Checked with a scope and the signals are working great.
i tried looking for an answer about the specific pins, but couldn't find any answer.
I know i can only use interrupt on digital pins so there shouldn't be any problem with firing the interrupts...
(just to mention - reading the pins with digitalread is working but the teensy is missing changes)
any help would be highly appreciated...
here is the code:
Code:
void setup() {
pinMode (encoderF9A, INPUT); // pin 11
pinMode (encoderF9B, INPUT);
pinMode (encoderF14A, INPUT); // analog pin
pinMode (encoderF14B, INPUT); // pin 13
attachInterrupt(digitalPinToInterrupt(13), StateofF14B, RISING);
attachInterrupt(digitalPinToInterrupt(11), StateofF9A, FALLING);
}
void StateofF14B() {
encF14BstateCurrent = digitalReadFast(encoderF14B); // encoderF14B - pin 13
if ((encF14Bstatelast == LOW) && (encF14BstateCurrent == HIGH)){
if (digitalReadFast(encoderF14A) == HIGH){
Serial.println ("left");
encF14btnleft = true;
} else {
Serial.println ("right");
encF14btnright = true;
}
}
encF14Bstatelast = encF14BstateCurrent;
}// StateofF14A
//----stateofF9A
void StateofF9A(){
Serial.println("ISR F9A");// just to check if its even get into the ISR
encF9AstateCurrent = digitalReadFast(encoderF9A); // encoderF9A - pin 11
if ((encF9Astatelast == LOW) && (encF9AstateCurrent == HIGH)){
if (digitalReadFast(encoderF9B) == HIGH){
Serial.println("right");
encF9btnright = true;
} else {
encF9btnleft = true;
Serial.println("left");
}
}
encF9Astatelast = encF9AstateCurrent;
}// Stateof F9
i would also like to know what is the correct syntax to use with more then 1 hat switch? should i declare something?
That is when using the many axis joystick code.
Thanks.
Last edited: