Hi all,
Very new to the Teensy world and looking for some advise and perhaps a guide in the right direction. Sorry if my terminology is not correct.
I am building a gaming Sim Wheel. I am wanting to run 11 encoders in which they would make adjustments to in car controls in a sim game. Basically an up and down button i guess you might say.
Encoders are connected as code below with all centre pins daisy chained to ground
I have uploaded the Teensy/ encoder/ twoknobs example and have edited it to show my 11 encoders. With the serial monitor i can see all encoders and make them count up and down however when rotated i get the odd jump in my steps (count)?
I am also lost as to how to add an analogue input which i would use a potentiometer as a paddle clutch.
The other issue i have is that this doesnt make the teensy a windows USB game device.
As i said i am very new to this and just looking for some assistance please.
Code i am using follows -
*******************************************************************************************
#include <Encoder.h>
// Change these pin numbers to the pins connected to your encoder.
// Best Performance: both pins have interrupt capability
// Good Performance: only the first pin has interrupt capability
// Low Performance: neither pin has interrupt capability
Encoder encoder1(0, 1);
Encoder encoder2(2, 3);
Encoder encoder3(4, 5);
Encoder encoder4(6, 7);
Encoder encoder5(8, 9);
Encoder encoder6(10, 11);
Encoder encoder7(12, 14);
Encoder encoder8(15, 16);
Encoder encoder9(17, 18);
Encoder encoder10(19, 20);
Encoder encoder11(21, 22);
// avoid using pins with LEDs attached
void setup() {
Serial.begin(9600);
Serial.println("Encoder Clutch:");
}
long position1 = -999;
long position2 = -999;
long position3 = -999;
long position4 = -999;
long position5 = -999;
long position6 = -999;
long position7 = -999;
long position8 = -999;
long position9 = -999;
long position10 = -999;
long position11 = -999;
void loop() {
long enc1, enc2, enc3, enc4, enc5, enc6, enc7, enc8, enc9, enc10, enc11;
enc1 = encoder1.read();
enc2 = encoder2.read();
enc3 = encoder3.read();
enc4 = encoder4.read();
enc5 = encoder5.read();
enc6 = encoder6.read();
enc7 = encoder7.read();
enc8 = encoder8.read();
enc9 = encoder9.read();
enc10 = encoder10.read();
enc11 = encoder11.read();
if (enc1 != position1 || enc2 != position2 || enc3 !=position3 || enc4 != position4 || enc5 !=position5 || enc6 != position6 || enc7 !=position7 || enc8 != position8 || enc9 !=position9 || enc10 != position10 || enc11 !=position11) {
Serial.print("Encoder1 = ");
Serial.print(enc1);
Serial.print(", Encoder2 = ");
Serial.print(enc2);
Serial.print(", Encoder3 = ");
Serial.print(enc3);
Serial.print(", Encoder4 = ");
Serial.print(enc4);
Serial.print(", Encoder5 = ");
Serial.print(enc5);
Serial.print(", Encoder6 = ");
Serial.print(enc6);
Serial.print(", Encoder7 = ");
Serial.print(enc7);
Serial.print(", Encoder8 = ");
Serial.print(enc8);
Serial.print(", Encoder9 = ");
Serial.print(enc9);
Serial.print(", Encoder10 = ");
Serial.print(enc10);
Serial.print(", Encoder11 = ");
Serial.print(enc11);
Serial.println();
position1 = enc1;
position2 = enc2;
position3 = enc3;
position4 = enc4;
position5 = enc5;
position6 = enc6;
position7 = enc7;
position8 = enc8;
position9 = enc9;
position10 = enc10;
position11 = enc11;
}
// if a character is sent from the serial monitor,
// reset both back to zero.
if (Serial.available()) {
Serial.read();
Serial.println("Reset both knobs to zero");
encoder1.write(0);
encoder2.write(0);
encoder3.write(0);
encoder4.write(0);
encoder5.write(0);
encoder6.write(0);
encoder7.write(0);
encoder8.write(0);
encoder9.write(0);
encoder10.write(0);
encoder11.write(0);
}
}
I have also uploaded the examples/teensy/usb_joystick sketch and can then see teensy as a usb game controller however the button do very wierd and wonderful things when encoder turned and obviously dont count correctly.
Any help would be greatly appreciated
Very new to the Teensy world and looking for some advise and perhaps a guide in the right direction. Sorry if my terminology is not correct.
I am building a gaming Sim Wheel. I am wanting to run 11 encoders in which they would make adjustments to in car controls in a sim game. Basically an up and down button i guess you might say.
Encoders are connected as code below with all centre pins daisy chained to ground
I have uploaded the Teensy/ encoder/ twoknobs example and have edited it to show my 11 encoders. With the serial monitor i can see all encoders and make them count up and down however when rotated i get the odd jump in my steps (count)?
I am also lost as to how to add an analogue input which i would use a potentiometer as a paddle clutch.
The other issue i have is that this doesnt make the teensy a windows USB game device.
As i said i am very new to this and just looking for some assistance please.
Code i am using follows -
*******************************************************************************************
#include <Encoder.h>
// Change these pin numbers to the pins connected to your encoder.
// Best Performance: both pins have interrupt capability
// Good Performance: only the first pin has interrupt capability
// Low Performance: neither pin has interrupt capability
Encoder encoder1(0, 1);
Encoder encoder2(2, 3);
Encoder encoder3(4, 5);
Encoder encoder4(6, 7);
Encoder encoder5(8, 9);
Encoder encoder6(10, 11);
Encoder encoder7(12, 14);
Encoder encoder8(15, 16);
Encoder encoder9(17, 18);
Encoder encoder10(19, 20);
Encoder encoder11(21, 22);
// avoid using pins with LEDs attached
void setup() {
Serial.begin(9600);
Serial.println("Encoder Clutch:");
}
long position1 = -999;
long position2 = -999;
long position3 = -999;
long position4 = -999;
long position5 = -999;
long position6 = -999;
long position7 = -999;
long position8 = -999;
long position9 = -999;
long position10 = -999;
long position11 = -999;
void loop() {
long enc1, enc2, enc3, enc4, enc5, enc6, enc7, enc8, enc9, enc10, enc11;
enc1 = encoder1.read();
enc2 = encoder2.read();
enc3 = encoder3.read();
enc4 = encoder4.read();
enc5 = encoder5.read();
enc6 = encoder6.read();
enc7 = encoder7.read();
enc8 = encoder8.read();
enc9 = encoder9.read();
enc10 = encoder10.read();
enc11 = encoder11.read();
if (enc1 != position1 || enc2 != position2 || enc3 !=position3 || enc4 != position4 || enc5 !=position5 || enc6 != position6 || enc7 !=position7 || enc8 != position8 || enc9 !=position9 || enc10 != position10 || enc11 !=position11) {
Serial.print("Encoder1 = ");
Serial.print(enc1);
Serial.print(", Encoder2 = ");
Serial.print(enc2);
Serial.print(", Encoder3 = ");
Serial.print(enc3);
Serial.print(", Encoder4 = ");
Serial.print(enc4);
Serial.print(", Encoder5 = ");
Serial.print(enc5);
Serial.print(", Encoder6 = ");
Serial.print(enc6);
Serial.print(", Encoder7 = ");
Serial.print(enc7);
Serial.print(", Encoder8 = ");
Serial.print(enc8);
Serial.print(", Encoder9 = ");
Serial.print(enc9);
Serial.print(", Encoder10 = ");
Serial.print(enc10);
Serial.print(", Encoder11 = ");
Serial.print(enc11);
Serial.println();
position1 = enc1;
position2 = enc2;
position3 = enc3;
position4 = enc4;
position5 = enc5;
position6 = enc6;
position7 = enc7;
position8 = enc8;
position9 = enc9;
position10 = enc10;
position11 = enc11;
}
// if a character is sent from the serial monitor,
// reset both back to zero.
if (Serial.available()) {
Serial.read();
Serial.println("Reset both knobs to zero");
encoder1.write(0);
encoder2.write(0);
encoder3.write(0);
encoder4.write(0);
encoder5.write(0);
encoder6.write(0);
encoder7.write(0);
encoder8.write(0);
encoder9.write(0);
encoder10.write(0);
encoder11.write(0);
}
}
I have also uploaded the examples/teensy/usb_joystick sketch and can then see teensy as a usb game controller however the button do very wierd and wonderful things when encoder turned and obviously dont count correctly.
Any help would be greatly appreciated
Last edited: