Hi everyone,
I am new to this forum. I recently purchased a Teensy 4.1 and I'm using it on a Flight Simulator switch panel. I am using almost all the pins as input for switches and rotary knobs, but only pin 1 - 31 are being recognized. I have gone as far as to disconnect a the wire from a switch (pin) and works and tried it on each pin from 32 onwards, but still doesn't work. I don't know if I have a bad board or a bad code. I have a Teensy 4.0 in another switch box and it works just fine. The program that I'm using to write the code is Arduino 1.8.13.
My settings are:
Board: Teensy 4.1
USD Type: Flight Sim Controls + Joystick
CPU Speed: 600 MHz
Optimize: Faster
Port: "hid#vid_16c0&pid_0488 FlightSim (Teensy 4.1)"
Any help would be greatly appreciated.
Here is my code, it's pretty simple.
#include <Bounce.h>
#include <elapsedMillis.h>
#include <Rotary.h>
Bounce button_13 = Bounce(13, 10); // 10 = 10 ms debounce time
Bounce button_14 = Bounce(14, 10); // which is appropriate for
Bounce button_15 = Bounce(15, 10); // most mechanical pushbuttons
Bounce button_16 = Bounce(16, 10);
Bounce button_17 = Bounce(17, 10);
Bounce button_18 = Bounce(18, 10);
Bounce button_19 = Bounce(19, 10);
Bounce button_20 = Bounce(20, 10);
Bounce button_23 = Bounce(23, 10);
Bounce button_24 = Bounce(24, 10);
Bounce button_25 = Bounce(25, 10);
Bounce button_26 = Bounce(26, 10);
Bounce button_27 = Bounce(27, 10);
Bounce button_28 = Bounce(28, 10);
Bounce button_29 = Bounce(29, 10);
Bounce button_30 = Bounce(30, 10);
Bounce button_31 = Bounce(31, 10);
Bounce button_32 = Bounce(32, 10);
Bounce button_33 = Bounce(33, 10);
Bounce button_34 = Bounce(34, 10);
Bounce button_35 = Bounce(35, 10);
Bounce button_36 = Bounce(36, 10);
Bounce button_37 = Bounce(37, 10);
Bounce button_38 = Bounce(38, 10);
Bounce button_39 = Bounce(39, 10);
Bounce button_40 = Bounce(40, 10);
Bounce button_41 = Bounce(41, 10);
Bounce button_48 = Bounce(48, 10);
Bounce button_49 = Bounce(49, 10);
Bounce button_50 = Bounce(50, 10);
Bounce button_51 = Bounce(51, 10);
Bounce button_52 = Bounce(52, 10);
Bounce button_53 = Bounce(53, 10);
Bounce button_54 = Bounce(54, 10);
elapsedMillis timeElapsed;
unsigned int enc_interval = 50; //interval for encoders
Rotary rotary1 = Rotary(1, 2);
Rotary rotary2 = Rotary(3, 4);
Rotary rotary3 = Rotary(5, 6);
Rotary rotary4 = Rotary(7, 8);
Rotary rotary5 = Rotary(9, 10);
Rotary rotary6 = Rotary(11, 12);
void setup() {
attachInterrupt(1, rotate, CHANGE);
attachInterrupt(2, rotate, CHANGE);
attachInterrupt(3, rotate, CHANGE);
attachInterrupt(4, rotate, CHANGE);
attachInterrupt(5, rotate, CHANGE);
attachInterrupt(6, rotate, CHANGE);
attachInterrupt(7, rotate, CHANGE);
attachInterrupt(8, rotate, CHANGE);
attachInterrupt(9, rotate, CHANGE);
attachInterrupt(10, rotate, CHANGE);
attachInterrupt(11, rotate, CHANGE);
attachInterrupt(12, rotate, CHANGE);
pinMode(13, INPUT_PULLUP);
pinMode(14, INPUT_PULLUP);
pinMode(15, INPUT_PULLUP);
pinMode(16, INPUT_PULLUP);
pinMode(17, INPUT_PULLUP);
pinMode(18, INPUT_PULLUP);
pinMode(19, INPUT_PULLUP);
pinMode(20, INPUT_PULLUP);
pinMode(23, INPUT_PULLUP);
pinMode(24, INPUT_PULLUP);
pinMode(25, INPUT_PULLUP);
pinMode(26, INPUT_PULLUP);
pinMode(27, INPUT_PULLUP);
pinMode(28, INPUT_PULLUP);
pinMode(29, INPUT_PULLUP);
pinMode(30, INPUT_PULLUP);
pinMode(31, INPUT_PULLUP);
pinMode(32, INPUT_PULLUP);
pinMode(33, INPUT_PULLUP);
pinMode(34, INPUT_PULLUP);
pinMode(35, INPUT_PULLUP);
pinMode(36, INPUT_PULLUP);
pinMode(37, INPUT_PULLUP);
pinMode(38, INPUT_PULLUP);
pinMode(39, INPUT_PULLUP);
pinMode(40, INPUT_PULLUP);
pinMode(41, INPUT_PULLUP);
pinMode(48, INPUT_PULLUP);
pinMode(49, INPUT_PULLUP);
pinMode(50, INPUT_PULLUP);
pinMode(51, INPUT_PULLUP);
pinMode(52, INPUT_PULLUP);
pinMode(53, INPUT_PULLUP);
pinMode(54, INPUT_PULLUP);
}
void loop() {
// read 6 analog inputs and use them for the joystick axis
Joystick.sliderLeft(analogRead(21));
Joystick.sliderRight(analogRead(22));
if (timeElapsed > enc_interval) {
Joystick.button(1,0);
Joystick.button(2,0);
Joystick.button(3,0);
Joystick.button(4,0);
Joystick.button(5,0);
Joystick.button(6,0);
Joystick.button(7,0);
Joystick.button(8,0);
Joystick.button(9,0);
Joystick.button(10,0);
Joystick.button(11,0);
Joystick.button(12,0);
}
//UPDATE BUTTONS
button_13.update();
button_14.update();
button_15.update();
button_16.update();
button_17.update();
button_18.update();
button_19.update();
button_20.update();
button_23.update();
button_24.update();
button_25.update();
button_26.update();
button_27.update();
button_28.update();
button_29.update();
button_30.update();
button_31.update();
button_32.update();
button_33.update();
button_34.update();
button_35.update();
button_36.update();
button_37.update();
button_38.update();
button_39.update();
button_40.update();
button_41.update();
button_48.update();
button_49.update();
button_50.update();
button_51.update();
button_52.update();
button_53.update();
button_54.update();
// Check each button for "falling" edge.
// Update the Joystick buttons only upon changes.
// falling = high (not pressed - voltage from pullup resistor)
// to low (pressed - button connects pin to ground)
if (button_13.fallingEdge()) {
Joystick.button(14, 1);
}
if (button_14.fallingEdge()) {
Joystick.button(15, 1);
}
if (button_15.fallingEdge()) {
Joystick.button(16, 1);
}
if (button_16.fallingEdge()) {
Joystick.button(17, 1);
}
if (button_17.fallingEdge()) {
Joystick.button(18, 1);
}
if (button_18.fallingEdge()) {
Joystick.button(19, 1);
}
if (button_19.fallingEdge()) {
Joystick.button(20, 1);
}
if (button_20.fallingEdge()) {
Joystick.button(21, 1);
}
if (button_23.fallingEdge()) {
Joystick.button(24, 1);
}
if (button_24.fallingEdge()) {
Joystick.button(25, 1);
}
if (button_25.fallingEdge()) {
Joystick.button(26, 1);
}
if (button_26.fallingEdge()) {
Joystick.button(27, 1);
}
if (button_27.fallingEdge()) {
Joystick.button(28, 1);
}
if (button_28.fallingEdge()) {
Joystick.button(29, 1);
}
if (button_29.fallingEdge()) {
Joystick.button(30, 1);
}
if (button_30.fallingEdge()) {
Joystick.button(31, 1);
}
if (button_31.fallingEdge()) {
Joystick.button(32, 1);
}
if (button_32.fallingEdge()) {
Joystick.button(33, 1);
}
if (button_33.fallingEdge()) {
Joystick.button(34, 1);
}
if (button_34.fallingEdge()) {
Joystick.button(35, 1);
}
if (button_35.fallingEdge()) {
Joystick.button(36, 1);
}
if (button_36.fallingEdge()) {
Joystick.button(37, 1);
}
if (button_37.fallingEdge()) {
Joystick.button(38, 1);
}
if (button_38.fallingEdge()) {
Joystick.button(39, 1);
}
if (button_39.fallingEdge()) {
Joystick.button(40, 1);
}
if (button_40.fallingEdge()) {
Joystick.button(41, 1);
}
if (button_41.fallingEdge()) {
Joystick.button(42, 1);
}
if (button_48.fallingEdge()) {
Joystick.button(49, 1);
}
if (button_49.fallingEdge()) {
Joystick.button(50, 1);
}
if (button_50.fallingEdge()) {
Joystick.button(51, 1);
}
if (button_51.fallingEdge()) {
Joystick.button(52, 1);
}
if (button_52.fallingEdge()) {
Joystick.button(53, 1);
}
if (button_53.fallingEdge()) {
Joystick.button(54, 1);
}
if (button_54.fallingEdge()) {
Joystick.button(55, 1);
}
// Check each button for "rising" edge
// Update the Joystick buttons only upon changes.
// rising = low (pressed - button connects pin to ground)
// to high (not pressed - voltage from pullup resistor)
if (button_13.risingEdge()) {
Joystick.button(15, 0);
}
if (button_14.risingEdge()) {
Joystick.button(15, 0);
}
if (button_15.risingEdge()) {
Joystick.button(16, 0);
}
if (button_16.risingEdge()) {
Joystick.button(17, 0);
}
if (button_17.risingEdge()) {
Joystick.button(18, 0);
}
if (button_18.risingEdge()) {
Joystick.button(19, 0);
}
if (button_19.risingEdge()) {
Joystick.button(20, 0);
}
if (button_20.risingEdge()) {
Joystick.button(21, 0);
}
if (button_23.risingEdge()) {
Joystick.button(24, 0);
}
if (button_24.risingEdge()) {
Joystick.button(25, 0);
}
if (button_25.risingEdge()) {
Joystick.button(26, 0);
}
if (button_26.risingEdge()) {
Joystick.button(27, 0);
}
if (button_27.risingEdge()) {
Joystick.button(28, 0);
}
if (button_28.risingEdge()) {
Joystick.button(29, 0);
}
if (button_30.risingEdge()) {
Joystick.button(31, 0);
}
if (button_31.risingEdge()) {
Joystick.button(32, 0);
}
if (button_32.risingEdge()) {
Joystick.button(33, 0);
}
if (button_33.risingEdge()) {
Joystick.button(34, 0);
}
if (button_34.risingEdge()) {
Joystick.button(35, 0);
}
if (button_35.risingEdge()) {
Joystick.button(36, 0);
}
if (button_36.risingEdge()) {
Joystick.button(37, 0);
}
if (button_37.risingEdge()) {
Joystick.button(38, 0);
}
if (button_38.risingEdge()) {
Joystick.button(39, 0);
}
if (button_39.risingEdge()) {
Joystick.button(40, 0);
}
if (button_40.risingEdge()) {
Joystick.button(41, 0);
}
if (button_41.risingEdge()) {
Joystick.button(42, 0);
}
if (button_48.risingEdge()) {
Joystick.button(49, 0);
}
if (button_49.risingEdge()) {
Joystick.button(50, 0);
}
if (button_50.risingEdge()) {
Joystick.button(51, 0);
}
if (button_51.risingEdge()) {
Joystick.button(52, 0);
}
if (button_52.risingEdge()) {
Joystick.button(53, 0);
}
if (button_53.risingEdge()) {
Joystick.button(54, 0);
}
if (button_54.risingEdge()) {
Joystick.button(55, 0);
}
}
void rotate() {
// HANDLE ENCODER 1
unsigned char result1 = rotary1.process();
if (result1 == DIR_CW) {
timeElapsed = 0;
Joystick.button(1,1);
Joystick.button(2,0);
} else if (result1 == DIR_CCW) {
timeElapsed = 0;
Joystick.button(2,1);
Joystick.button(1,0);
}
// HANDLE ENCODER 2
unsigned char result2 = rotary2.process();
if (result2 == DIR_CW) {
timeElapsed = 0;
Joystick.button(3,1);
Joystick.button(4,0);
} else if (result2 == DIR_CCW) {
timeElapsed = 0;
Joystick.button(4,1);
Joystick.button(3,0);
}
// HANDLE ENCODER 3
unsigned char result3 = rotary3.process();
if (result3 == DIR_CW) {
timeElapsed = 0;
Joystick.button(5,1);
Joystick.button(6,0);
} else if (result3 == DIR_CCW) {
timeElapsed = 0;
Joystick.button(6,1);
Joystick.button(5,0);
}
// HANDLE ENCODER 4
unsigned char result4 = rotary4.process();
if (result4 == DIR_CW) {
timeElapsed = 0;
Joystick.button(7,1);
Joystick.button(8,0);
} else if (result4 == DIR_CCW) {
timeElapsed = 0;
Joystick.button(8,1);
Joystick.button(7,0);
}
// HANDLE ENCODER 5
unsigned char result5 = rotary5.process();
if (result5 == DIR_CW) {
timeElapsed = 0;
Joystick.button(9,1);
Joystick.button(10,0);
} else if (result5 == DIR_CCW) {
timeElapsed = 0;
Joystick.button(10,1);
Joystick.button(9,0);
}
// HANDLE ENCODER 6
unsigned char result6 = rotary6.process();
if (result6 == DIR_CW) {
timeElapsed = 0;
Joystick.button(11,1);
Joystick.button(12,0);
} else if (result6 == DIR_CCW) {
timeElapsed = 0;
Joystick.button(12,1);
Joystick.button(11,0);
}
}
I am new to this forum. I recently purchased a Teensy 4.1 and I'm using it on a Flight Simulator switch panel. I am using almost all the pins as input for switches and rotary knobs, but only pin 1 - 31 are being recognized. I have gone as far as to disconnect a the wire from a switch (pin) and works and tried it on each pin from 32 onwards, but still doesn't work. I don't know if I have a bad board or a bad code. I have a Teensy 4.0 in another switch box and it works just fine. The program that I'm using to write the code is Arduino 1.8.13.
My settings are:
Board: Teensy 4.1
USD Type: Flight Sim Controls + Joystick
CPU Speed: 600 MHz
Optimize: Faster
Port: "hid#vid_16c0&pid_0488 FlightSim (Teensy 4.1)"
Any help would be greatly appreciated.
Here is my code, it's pretty simple.
#include <Bounce.h>
#include <elapsedMillis.h>
#include <Rotary.h>
Bounce button_13 = Bounce(13, 10); // 10 = 10 ms debounce time
Bounce button_14 = Bounce(14, 10); // which is appropriate for
Bounce button_15 = Bounce(15, 10); // most mechanical pushbuttons
Bounce button_16 = Bounce(16, 10);
Bounce button_17 = Bounce(17, 10);
Bounce button_18 = Bounce(18, 10);
Bounce button_19 = Bounce(19, 10);
Bounce button_20 = Bounce(20, 10);
Bounce button_23 = Bounce(23, 10);
Bounce button_24 = Bounce(24, 10);
Bounce button_25 = Bounce(25, 10);
Bounce button_26 = Bounce(26, 10);
Bounce button_27 = Bounce(27, 10);
Bounce button_28 = Bounce(28, 10);
Bounce button_29 = Bounce(29, 10);
Bounce button_30 = Bounce(30, 10);
Bounce button_31 = Bounce(31, 10);
Bounce button_32 = Bounce(32, 10);
Bounce button_33 = Bounce(33, 10);
Bounce button_34 = Bounce(34, 10);
Bounce button_35 = Bounce(35, 10);
Bounce button_36 = Bounce(36, 10);
Bounce button_37 = Bounce(37, 10);
Bounce button_38 = Bounce(38, 10);
Bounce button_39 = Bounce(39, 10);
Bounce button_40 = Bounce(40, 10);
Bounce button_41 = Bounce(41, 10);
Bounce button_48 = Bounce(48, 10);
Bounce button_49 = Bounce(49, 10);
Bounce button_50 = Bounce(50, 10);
Bounce button_51 = Bounce(51, 10);
Bounce button_52 = Bounce(52, 10);
Bounce button_53 = Bounce(53, 10);
Bounce button_54 = Bounce(54, 10);
elapsedMillis timeElapsed;
unsigned int enc_interval = 50; //interval for encoders
Rotary rotary1 = Rotary(1, 2);
Rotary rotary2 = Rotary(3, 4);
Rotary rotary3 = Rotary(5, 6);
Rotary rotary4 = Rotary(7, 8);
Rotary rotary5 = Rotary(9, 10);
Rotary rotary6 = Rotary(11, 12);
void setup() {
attachInterrupt(1, rotate, CHANGE);
attachInterrupt(2, rotate, CHANGE);
attachInterrupt(3, rotate, CHANGE);
attachInterrupt(4, rotate, CHANGE);
attachInterrupt(5, rotate, CHANGE);
attachInterrupt(6, rotate, CHANGE);
attachInterrupt(7, rotate, CHANGE);
attachInterrupt(8, rotate, CHANGE);
attachInterrupt(9, rotate, CHANGE);
attachInterrupt(10, rotate, CHANGE);
attachInterrupt(11, rotate, CHANGE);
attachInterrupt(12, rotate, CHANGE);
pinMode(13, INPUT_PULLUP);
pinMode(14, INPUT_PULLUP);
pinMode(15, INPUT_PULLUP);
pinMode(16, INPUT_PULLUP);
pinMode(17, INPUT_PULLUP);
pinMode(18, INPUT_PULLUP);
pinMode(19, INPUT_PULLUP);
pinMode(20, INPUT_PULLUP);
pinMode(23, INPUT_PULLUP);
pinMode(24, INPUT_PULLUP);
pinMode(25, INPUT_PULLUP);
pinMode(26, INPUT_PULLUP);
pinMode(27, INPUT_PULLUP);
pinMode(28, INPUT_PULLUP);
pinMode(29, INPUT_PULLUP);
pinMode(30, INPUT_PULLUP);
pinMode(31, INPUT_PULLUP);
pinMode(32, INPUT_PULLUP);
pinMode(33, INPUT_PULLUP);
pinMode(34, INPUT_PULLUP);
pinMode(35, INPUT_PULLUP);
pinMode(36, INPUT_PULLUP);
pinMode(37, INPUT_PULLUP);
pinMode(38, INPUT_PULLUP);
pinMode(39, INPUT_PULLUP);
pinMode(40, INPUT_PULLUP);
pinMode(41, INPUT_PULLUP);
pinMode(48, INPUT_PULLUP);
pinMode(49, INPUT_PULLUP);
pinMode(50, INPUT_PULLUP);
pinMode(51, INPUT_PULLUP);
pinMode(52, INPUT_PULLUP);
pinMode(53, INPUT_PULLUP);
pinMode(54, INPUT_PULLUP);
}
void loop() {
// read 6 analog inputs and use them for the joystick axis
Joystick.sliderLeft(analogRead(21));
Joystick.sliderRight(analogRead(22));
if (timeElapsed > enc_interval) {
Joystick.button(1,0);
Joystick.button(2,0);
Joystick.button(3,0);
Joystick.button(4,0);
Joystick.button(5,0);
Joystick.button(6,0);
Joystick.button(7,0);
Joystick.button(8,0);
Joystick.button(9,0);
Joystick.button(10,0);
Joystick.button(11,0);
Joystick.button(12,0);
}
//UPDATE BUTTONS
button_13.update();
button_14.update();
button_15.update();
button_16.update();
button_17.update();
button_18.update();
button_19.update();
button_20.update();
button_23.update();
button_24.update();
button_25.update();
button_26.update();
button_27.update();
button_28.update();
button_29.update();
button_30.update();
button_31.update();
button_32.update();
button_33.update();
button_34.update();
button_35.update();
button_36.update();
button_37.update();
button_38.update();
button_39.update();
button_40.update();
button_41.update();
button_48.update();
button_49.update();
button_50.update();
button_51.update();
button_52.update();
button_53.update();
button_54.update();
// Check each button for "falling" edge.
// Update the Joystick buttons only upon changes.
// falling = high (not pressed - voltage from pullup resistor)
// to low (pressed - button connects pin to ground)
if (button_13.fallingEdge()) {
Joystick.button(14, 1);
}
if (button_14.fallingEdge()) {
Joystick.button(15, 1);
}
if (button_15.fallingEdge()) {
Joystick.button(16, 1);
}
if (button_16.fallingEdge()) {
Joystick.button(17, 1);
}
if (button_17.fallingEdge()) {
Joystick.button(18, 1);
}
if (button_18.fallingEdge()) {
Joystick.button(19, 1);
}
if (button_19.fallingEdge()) {
Joystick.button(20, 1);
}
if (button_20.fallingEdge()) {
Joystick.button(21, 1);
}
if (button_23.fallingEdge()) {
Joystick.button(24, 1);
}
if (button_24.fallingEdge()) {
Joystick.button(25, 1);
}
if (button_25.fallingEdge()) {
Joystick.button(26, 1);
}
if (button_26.fallingEdge()) {
Joystick.button(27, 1);
}
if (button_27.fallingEdge()) {
Joystick.button(28, 1);
}
if (button_28.fallingEdge()) {
Joystick.button(29, 1);
}
if (button_29.fallingEdge()) {
Joystick.button(30, 1);
}
if (button_30.fallingEdge()) {
Joystick.button(31, 1);
}
if (button_31.fallingEdge()) {
Joystick.button(32, 1);
}
if (button_32.fallingEdge()) {
Joystick.button(33, 1);
}
if (button_33.fallingEdge()) {
Joystick.button(34, 1);
}
if (button_34.fallingEdge()) {
Joystick.button(35, 1);
}
if (button_35.fallingEdge()) {
Joystick.button(36, 1);
}
if (button_36.fallingEdge()) {
Joystick.button(37, 1);
}
if (button_37.fallingEdge()) {
Joystick.button(38, 1);
}
if (button_38.fallingEdge()) {
Joystick.button(39, 1);
}
if (button_39.fallingEdge()) {
Joystick.button(40, 1);
}
if (button_40.fallingEdge()) {
Joystick.button(41, 1);
}
if (button_41.fallingEdge()) {
Joystick.button(42, 1);
}
if (button_48.fallingEdge()) {
Joystick.button(49, 1);
}
if (button_49.fallingEdge()) {
Joystick.button(50, 1);
}
if (button_50.fallingEdge()) {
Joystick.button(51, 1);
}
if (button_51.fallingEdge()) {
Joystick.button(52, 1);
}
if (button_52.fallingEdge()) {
Joystick.button(53, 1);
}
if (button_53.fallingEdge()) {
Joystick.button(54, 1);
}
if (button_54.fallingEdge()) {
Joystick.button(55, 1);
}
// Check each button for "rising" edge
// Update the Joystick buttons only upon changes.
// rising = low (pressed - button connects pin to ground)
// to high (not pressed - voltage from pullup resistor)
if (button_13.risingEdge()) {
Joystick.button(15, 0);
}
if (button_14.risingEdge()) {
Joystick.button(15, 0);
}
if (button_15.risingEdge()) {
Joystick.button(16, 0);
}
if (button_16.risingEdge()) {
Joystick.button(17, 0);
}
if (button_17.risingEdge()) {
Joystick.button(18, 0);
}
if (button_18.risingEdge()) {
Joystick.button(19, 0);
}
if (button_19.risingEdge()) {
Joystick.button(20, 0);
}
if (button_20.risingEdge()) {
Joystick.button(21, 0);
}
if (button_23.risingEdge()) {
Joystick.button(24, 0);
}
if (button_24.risingEdge()) {
Joystick.button(25, 0);
}
if (button_25.risingEdge()) {
Joystick.button(26, 0);
}
if (button_26.risingEdge()) {
Joystick.button(27, 0);
}
if (button_27.risingEdge()) {
Joystick.button(28, 0);
}
if (button_28.risingEdge()) {
Joystick.button(29, 0);
}
if (button_30.risingEdge()) {
Joystick.button(31, 0);
}
if (button_31.risingEdge()) {
Joystick.button(32, 0);
}
if (button_32.risingEdge()) {
Joystick.button(33, 0);
}
if (button_33.risingEdge()) {
Joystick.button(34, 0);
}
if (button_34.risingEdge()) {
Joystick.button(35, 0);
}
if (button_35.risingEdge()) {
Joystick.button(36, 0);
}
if (button_36.risingEdge()) {
Joystick.button(37, 0);
}
if (button_37.risingEdge()) {
Joystick.button(38, 0);
}
if (button_38.risingEdge()) {
Joystick.button(39, 0);
}
if (button_39.risingEdge()) {
Joystick.button(40, 0);
}
if (button_40.risingEdge()) {
Joystick.button(41, 0);
}
if (button_41.risingEdge()) {
Joystick.button(42, 0);
}
if (button_48.risingEdge()) {
Joystick.button(49, 0);
}
if (button_49.risingEdge()) {
Joystick.button(50, 0);
}
if (button_50.risingEdge()) {
Joystick.button(51, 0);
}
if (button_51.risingEdge()) {
Joystick.button(52, 0);
}
if (button_52.risingEdge()) {
Joystick.button(53, 0);
}
if (button_53.risingEdge()) {
Joystick.button(54, 0);
}
if (button_54.risingEdge()) {
Joystick.button(55, 0);
}
}
void rotate() {
// HANDLE ENCODER 1
unsigned char result1 = rotary1.process();
if (result1 == DIR_CW) {
timeElapsed = 0;
Joystick.button(1,1);
Joystick.button(2,0);
} else if (result1 == DIR_CCW) {
timeElapsed = 0;
Joystick.button(2,1);
Joystick.button(1,0);
}
// HANDLE ENCODER 2
unsigned char result2 = rotary2.process();
if (result2 == DIR_CW) {
timeElapsed = 0;
Joystick.button(3,1);
Joystick.button(4,0);
} else if (result2 == DIR_CCW) {
timeElapsed = 0;
Joystick.button(4,1);
Joystick.button(3,0);
}
// HANDLE ENCODER 3
unsigned char result3 = rotary3.process();
if (result3 == DIR_CW) {
timeElapsed = 0;
Joystick.button(5,1);
Joystick.button(6,0);
} else if (result3 == DIR_CCW) {
timeElapsed = 0;
Joystick.button(6,1);
Joystick.button(5,0);
}
// HANDLE ENCODER 4
unsigned char result4 = rotary4.process();
if (result4 == DIR_CW) {
timeElapsed = 0;
Joystick.button(7,1);
Joystick.button(8,0);
} else if (result4 == DIR_CCW) {
timeElapsed = 0;
Joystick.button(8,1);
Joystick.button(7,0);
}
// HANDLE ENCODER 5
unsigned char result5 = rotary5.process();
if (result5 == DIR_CW) {
timeElapsed = 0;
Joystick.button(9,1);
Joystick.button(10,0);
} else if (result5 == DIR_CCW) {
timeElapsed = 0;
Joystick.button(10,1);
Joystick.button(9,0);
}
// HANDLE ENCODER 6
unsigned char result6 = rotary6.process();
if (result6 == DIR_CW) {
timeElapsed = 0;
Joystick.button(11,1);
Joystick.button(12,0);
} else if (result6 == DIR_CCW) {
timeElapsed = 0;
Joystick.button(12,1);
Joystick.button(11,0);
}
}