Skip to content

Instantly share code, notes, and snippets.

View tigert's full-sized avatar

Tuomas Kuosmanen tigert

  • Helsinki, Finland
View GitHub Profile
@tigert
tigert / 3d-printed-throttle.ino
Last active February 7, 2023 16:39
USB HID Flight Simulator throttle and trim wheel using Arduino Pro Micro
// This is a remix of USB joystick sketch by Mark Bennett at the arduino hub:
// https://create.arduino.cc/projecthub/markbennettuk/throttle-quadrant-and-trim-wheel-d746e8
// I just include the Encoder library for my pitch trim wheel, and
// compare the encoder values during the loop, and spew out 10 button
// click events for each encoder pulse (because MS Flight Simulator 2020
// currently has ridiculously slow trim wheel input)
//
// Update: read the potentiometer values three times to stabilize them a bit.
// Apparently there is a capacitor on the arduino that is shared by all
// analog input pins. This takes a short moment to recharge when you
// This is a remix of USB joystick sketch by Mark Bennett at the arduino hub:
// https://create.arduino.cc/projecthub/markbennettuk/throttle-quadrant-and-trim-wheel-d746e8
// I use the Encoder library for my pitch trim wheel, limit the encoder internal counter to
// 0 to 1023 range in a crude way, and set that as the value for the trim axis.
//
// Update: read the potentiometer values three times to stabilize them a bit.
// Apparently there is a capacitor on the arduino that is shared by all
// analog input pins. This takes a short moment to recharge when you
// read another analog pin with a different voltage, thus the potentiometers
// were interfering with each other a bit. Doing a read (select the pin!),
// This is a remix of USB joystick sketch by Mark Bennett at the arduino hub:
// https://create.arduino.cc/projecthub/markbennettuk/throttle-quadrant-and-trim-wheel-d746e8
// I use the Encoder library for my pitch trim wheel, limit the encoder internal counter to
// 0 to 1023 range in a crude way, and set that as the value for the trim axis.
//
// Update: read the potentiometer values three times to stabilize them a bit.
// Apparently there is a capacitor on the arduino that is shared by all
// analog input pins. This takes a short moment to recharge when you
// read another analog pin with a different voltage, thus the potentiometers
// were interfering with each other a bit. Doing a read (select the pin!),