1
\$\begingroup\$

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.

asked Dec 18, 2017 at 6:07
\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

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.

answered Jan 3, 2018 at 17:31
\$\endgroup\$
3
  • \$\begingroup\$ If this is a satisfactory solution you can accept it to indicate that the problem is solved. \$\endgroup\$ Commented Jan 3, 2018 at 19:46
  • \$\begingroup\$ It is, although I would rather see if anyone else post something better than this solution \$\endgroup\$ Commented 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\$ Commented Jun 2, 2021 at 8:30

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.