Devices & Components
Arduino Leonardo with Headers
Rotary potentiometer 50k, details in story section
Wire, Hook Up
Hardware & Tools
Soldering iron (generic)
3D Printer (generic)
Software & Tools
Arduino IDE
Project description
Code
Quadrant.ino
arduino
Use the setting variable and the serial monitor to find the end point values for each potentiometer, enter them into the axisLimits array. Use this joystick library, not the one found in the Arduino library manager, they are for different applications. https://github.com/MHeironimus/ArduinoJoystickLibrary
1#include <Joystick.h> 2 3Joystick_ Joystick; 4 5// put the max 6 and min values from the analogRead in these arrays 7// these are translated to 8 a range of 0 - 1023 9int axisLimits0[] = {686, 338}; 10int axisLimits1[] = {345, 11 695}; 12int axisLimits2[] = {327, 678}; 13int axisLimits3[] = {342, 692}; 14int 15 axisLimits4[] = {0, 1023}; 16int axisLimits5[] = {0, 1023}; 17 18// turn axes 19 on or off by setting these variables 20bool a0Used = true; 21bool a1Used = true; 22bool 23 a2Used = true; 24bool a3Used = true; 25bool a4Used = false; 26bool a5Used = false; 27 28// 29 setting mode prints the pin value and translated value to the serial monitor 30// 31 int setting = -1; // no printing to the serial monitor 32// int setting = 2; // 33 values 0 - 5, print the pin values to the serial monitor 34int setting = -1; 35 36void 37 setup() { 38 if(a0Used) pinMode(A0, INPUT); 39 if(a1Used) pinMode(A1, INPUT); 40 41 if(a2Used) pinMode(A2, INPUT); 42 if(a3Used) pinMode(A3, INPUT); 43 if(a4Used) 44 pinMode(A4, INPUT); 45 if(a5Used) pinMode(A5, INPUT); 46 Joystick.begin(); 47 48 if(setting >= 0) Serial.begin(9600); 49} 50 51void loop() { 52 int value 53 = 0; 54 int pos = 0; 55 56 if(a0Used){ 57 value = analogRead(A0); 58 pos 59 = translateValue(value, axisLimits0[0], axisLimits0[1]); 60 Joystick.setThrottle(pos); 61 62 if(setting == 0) settingPrint(value, pos); 63 } 64 65 if(a1Used){ 66 67 value = analogRead(A1); 68 pos = translateValue(value, axisLimits1[0], axisLimits1[1]); 69 70 Joystick.setRxAxis(pos); 71 if(setting == 1) settingPrint(value, pos); 72 73 } 74 75 if(a2Used){ 76 value = analogRead(A2); 77 pos = translateValue(value, 78 axisLimits2[0], axisLimits2[1]); 79 Joystick.setRyAxis(pos); 80 if(setting 81 == 2) settingPrint(value, pos); 82 } 83 84 if(a3Used){ 85 value = analogRead(A3); 86 87 pos = translateValue(value, axisLimits3[0], axisLimits3[1]); 88 Joystick.setRzAxis(pos); 89 90 if(setting == 3) settingPrint(value, pos); 91 } 92 93 if(a4Used){ 94 95 value = analogRead(A4); 96 pos = translateValue(value, axisLimits4[0], axisLimits4[1]); 97 98 Joystick.setXAxis(pos); 99 if(setting == 4) settingPrint(value, pos); 100 101 } 102 103 if(a5Used){ 104 value = analogRead(A5); 105 pos = translateValue(value, 106 axisLimits5[0], axisLimits5[1]); 107 Joystick.setYAxis(pos); 108 if(setting 109 == 5) settingPrint(value, pos); 110 } 111 112 delay(5); 113} 114 115int translateValue(int 116 v, int f1, int f2){ 117 // translates values to a 0 - 1023 range 118 int result 119 = 0; 120 int start = 0; 121 float range = 0; 122 123 if(f1 < f2){ 124 start 125 = f1; 126 range = f2 - f1; 127 } 128 else{ 129 start = f2; 130 range 131 = f1 - f2; 132 } 133 134 result = (v - start) * (1023 / range); 135 136 if(result 137 < 0) result = 0; 138 if(result > 1023) result = 1023; 139 140 return result; 141} 142 143void 144 settingPrint(int value, int pos){ 145 Serial.print(value); 146 Serial.print(" 147 "); 148 Serial.println(pos); 149} 150
Quadrant.ino
arduino
Use the setting variable and the serial monitor to find the end point values for each potentiometer, enter them into the axisLimits array. Use this joystick library, not the one found in the Arduino library manager, they are for different applications. https://github.com/MHeironimus/ArduinoJoystickLibrary
1#include <Joystick.h> 2 3Joystick_ Joystick; 4 5// put the max and min values from the analogRead in these arrays 6// these are translated to a range of 0 - 1023 7int axisLimits0[] = {686, 338}; 8int axisLimits1[] = {345, 695}; 9int axisLimits2[] = {327, 678}; 10int axisLimits3[] = {342, 692}; 11int axisLimits4[] = {0, 1023}; 12int axisLimits5[] = {0, 1023}; 13 14// turn axes on or off by setting these variables 15bool a0Used = true; 16bool a1Used = true; 17bool a2Used = true; 18bool a3Used = true; 19bool a4Used = false; 20bool a5Used = false; 21 22// setting mode prints the pin value and translated value to the serial monitor 23// int setting = -1; // no printing to the serial monitor 24// int setting = 2; // values 0 - 5, print the pin values to the serial monitor 25int setting = -1; 26 27void setup() { 28 if(a0Used) pinMode(A0, INPUT); 29 if(a1Used) pinMode(A1, INPUT); 30 if(a2Used) pinMode(A2, INPUT); 31 if(a3Used) pinMode(A3, INPUT); 32 if(a4Used) pinMode(A4, INPUT); 33 if(a5Used) pinMode(A5, INPUT); 34 Joystick.begin(); 35 if(setting >= 0) Serial.begin(9600); 36} 37 38void loop() { 39 int value = 0; 40 int pos = 0; 41 42 if(a0Used){ 43 value = analogRead(A0); 44 pos = translateValue(value, axisLimits0[0], axisLimits0[1]); 45 Joystick.setThrottle(pos); 46 if(setting == 0) settingPrint(value, pos); 47 } 48 49 if(a1Used){ 50 value = analogRead(A1); 51 pos = translateValue(value, axisLimits1[0], axisLimits1[1]); 52 Joystick.setRxAxis(pos); 53 if(setting == 1) settingPrint(value, pos); 54 } 55 56 if(a2Used){ 57 value = analogRead(A2); 58 pos = translateValue(value, axisLimits2[0], axisLimits2[1]); 59 Joystick.setRyAxis(pos); 60 if(setting == 2) settingPrint(value, pos); 61 } 62 63 if(a3Used){ 64 value = analogRead(A3); 65 pos = translateValue(value, axisLimits3[0], axisLimits3[1]); 66 Joystick.setRzAxis(pos); 67 if(setting == 3) settingPrint(value, pos); 68 } 69 70 if(a4Used){ 71 value = analogRead(A4); 72 pos = translateValue(value, axisLimits4[0], axisLimits4[1]); 73 Joystick.setXAxis(pos); 74 if(setting == 4) settingPrint(value, pos); 75 } 76 77 if(a5Used){ 78 value = analogRead(A5); 79 pos = translateValue(value, axisLimits5[0], axisLimits5[1]); 80 Joystick.setYAxis(pos); 81 if(setting == 5) settingPrint(value, pos); 82 } 83 84 delay(5); 85} 86 87int translateValue(int v, int f1, int f2){ 88 // translates values to a 0 - 1023 range 89 int result = 0; 90 int start = 0; 91 float range = 0; 92 93 if(f1 < f2){ 94 start = f1; 95 range = f2 - f1; 96 } 97 else{ 98 start = f2; 99 range = f1 - f2; 100 } 101 102 result = (v - start) * (1023 / range); 103 104 if(result < 0) result = 0; 105 if(result > 1023) result = 1023; 106 107 return result; 108} 109 110void settingPrint(int value, int pos){ 111 Serial.print(value); 112 Serial.print(" "); 113 Serial.println(pos); 114} 115
Downloadable files
Single potentiometer diagram
To add more controls hook up 5V and GRD and use pins A1 to A5
Single potentiometer diagram
Single potentiometer diagram
To add more controls hook up 5V and GRD and use pins A1 to A5
Single potentiometer diagram
Documentation
Back Box Narrow Centre
Back Box Narrow Centre
Body left
Body left
Knob for Flaps
Knob for Flaps
Back Box Wide End Left
Back Box Wide End Left
Back Box Narrow End Right
Back Box Narrow End Right
Lever with 4 Detents
Lever with 4 Detents
Trim Wheel Body Left
Trim Wheel Body Left
Trim Wheel Gear
Trim Wheel Gear
Back Box Wide Centre
Back Box Wide Centre
Knob for Throttle (Type 1)
Knob for Throttle (Type 1)
Knob for Landing Gear
Knob for Landing Gear
End Cap Plain (Optional)
One without the tab in case you need it
End Cap Plain (Optional)
Back Box Narrow End Left
Back Box Narrow End Left
Lever with 6 Detents
Lever with 6 Detents
Lever with 3 Detents
Lever with 3 Detents
Lever with 2 Detents
Lever with 2 Detents
Body Right
Body Right
End Cap Left
End Cap Left
Potentiometer Holder
Potentiometer Holder
Friction Plate Option 1 (Least friction)
Friction Plate Option 1 (Least friction)
Lever with 5 Detents
Lever with 5 Detents
Trim Wheel Single Piece (Option)
Trim Wheel Single Piece (Option)
Trim Wheel Body Right
Trim Wheel Body Right
Lever with 0 Detents
Lever with 0 Detents
End Cap Right
End Cap Right
Trim Wheel Quadrant Drive
Trim Wheel Quadrant Drive
Trim Wheel Quadrant
Trim Wheel Quadrant
Knob for Fuel Mixture
Knob for Fuel Mixture
Knob for Throttle (Type 2)
Knob for Throttle (Type 2)
Trim Wheel Wheel
Trim Wheel Wheel
Knob for Landing Gear
Knob for Landing Gear
Trim Wheel Quadrant Drive
Trim Wheel Quadrant Drive
Trim Wheel Single Piece (Option)
Trim Wheel Single Piece (Option)
Trim Wheel Wheel
Trim Wheel Wheel
Lever with 3 Detents
Lever with 3 Detents
Potentiometer Holder
Potentiometer Holder
Trim Wheel Body Left
Trim Wheel Body Left
Lever with 5 Detents
Lever with 5 Detents
Friction Plate Option 3 (Most friction)
Friction Plate Option 3 (Most friction)
Trim Wheel Body Right
Trim Wheel Body Right
Lever with 2 Detents
Lever with 2 Detents
Lever with 0 Detents
Lever with 0 Detents
Body left
Body left
Friction Plate Option 1 (Least friction)
Friction Plate Option 1 (Least friction)
Complete STEP File
This file contains all the parts as a STEP file
Complete STEP File
Knob for Fuel Mixture
Knob for Fuel Mixture
Trim Wheel Nodule
Trim Wheel Nodule
Back Box Narrow End Left
Back Box Narrow End Left
Trim Wheel Gear
Trim Wheel Gear
Lever with 6 Detents
Lever with 6 Detents
Back Box Narrow End Right
Back Box Narrow End Right
Back Box Wide Centre
Back Box Wide Centre
Knob for Flaps
Knob for Flaps
Back Box Narrow Centre
Back Box Narrow Centre
Lever with 4 Detents
Lever with 4 Detents
Knob for Propeller Pitch
Knob for Propeller Pitch
Knob for Throttle (Type 2)
Knob for Throttle (Type 2)
Friction Plate Option 2 (Middle friction)
The one I use
Friction Plate Option 2 (Middle friction)
Trim Wheel Hub
Trim Wheel Hub
Knob for Throttle (Type 1)
Knob for Throttle (Type 1)
Lever End
Lever End
Complete STEP File
This file contains all the parts as a STEP file
Complete STEP File
Trim Wheel Nodule
Trim Wheel Nodule
Body Right
Body Right
Knob for Propeller Pitch
Knob for Propeller Pitch
Friction Plate Option 2 (Middle friction)
The one I use
Friction Plate Option 2 (Middle friction)
Trim Wheel Hub
Trim Wheel Hub
Lever End
Lever End
End Cap Left
End Cap Left
End Cap Plain (Optional)
One without the tab in case you need it
End Cap Plain (Optional)
Trim Wheel Quadrant
Trim Wheel Quadrant
End Cap Right
End Cap Right
Back Box Wide End Left
Back Box Wide End Left
Comments
Only logged in users can leave comments