I am making a controller for my child; to be used in a video game on PC.
I did get a 11 position rotary switch, few toggle switch and a couple of potentiometers. Now, I did check few tutorials and I can see that most of them implement momentary switch; so I am trying to work a strategy to implement the other switches and the potentiometers. As board I am using a teensy 3.1
for the rotary switch I was thinking to connect the right 5 poles to the same signal, and the same with the left 5 poles; so all but the center pole will be connected, and if I turn it right is like if I am pressing the + button (like to increase the speed of a car), and - button if I go the other way. Is this acceptable or the signal while switching position may be missed or give me incorrect results?
For the toggle switch; can I just implement them in the same way as a momentary button? So when I enable the switch (so the circuit is open), a keyboard press message is sent, while when I disable the switch, the button is pressed again?
What about the potentiometer? Is there a way to have the buttons pressed when I rotate it in a direction or another? These are not rotary encoders so they stop at one point; and I was thinking that they could be helpful as a way to move through menu.
1 Answer 1
Some solutions that I did implement:
I did connect resistors between each pole of the rotary switch, up to the last one, skipping only the common pole for obvious reasons. Then I connected the first notch to positive, the last notch to negative and the common pin to one of the analog input of the controller; so when I read the values; I get finite steps between each notch; and as such, I can implement the various increase and decrease values that I need.
The toggle switch has been implemented as matrix; so I use 2 pins for each of them, and watch for the hold and release state, to figure out what to do.
The potentiometer was implemented as analog axis directly in the microcontroller; straightforward data read from the analog input, with a bit of normalization to avoid fluctuation.
-
\$\begingroup\$ If this is a satisfactory solution you can accept it to indicate that the problem is solved. \$\endgroup\$Transistor– Transistor2018年01月03日 19:46:39 +00:00Commented Jan 3, 2018 at 19:46
-
\$\begingroup\$ It is, although I would rather see if anyone else post something better than this solution \$\endgroup\$rataplan– rataplan2018年01月03日 21:41:32 +00:00Commented Jan 3, 2018 at 21:41
-
\$\begingroup\$ Looks like a good solution. You could also save 11 resistors if you have 11 unused digital I/O lines. Also, remember to debounce the momentary push switch. \$\endgroup\$Indraneel– Indraneel2021年06月02日 08:30:25 +00:00Commented Jun 2, 2021 at 8:30