6 way rotary switch connected to arduino uno to one analogic input

Hi everyone, this is my first post on this forum so i thought this is the best section to post in. So my apologies if it is not.

This is what i want to make: i want to control the direction of 4 dc motors using an arduino uno. i do that using two L293DNE to control the direction of the 4 dc motors (CW and CCW for specified periods of time). That i already did.

What i want to do more is to set 6 ways the motors will behave using 4 6-way rotary switches (one for each motor).

  1. motor off
  2. motor spin CW continuously
  3. motor spin CCW continuously
  4. motor spin CW for 3min/hour
  5. motor spin CCW for 3min/hour
  6. moro spin CW and CCW (alternate) for 3 min/hour

My question is: Since i don't have 24 digital input pins on my arduino uno i am thinking of using the rotary switch with resistors and connect each rotary switch to an analog input pin.

i did some research on this forum and i saw that i have to connect resistors to every pin on the rotary switch and then read the input through the analog input pin (which will differ because of the resistors)

what i don't know is how do i connect the rotary switch with the resistors to the arduino uno.

My thoughts:

  1. the common wire (the four pins in the middle of the rotary switch) go to the ground of the arduino
  2. connect one wire from the first pin of the rotary switch to the +5v pin on the arduino
  3. connect one wire from the 6th pin of the rotary switch to one analog input pin on the arduino (the one i do the reading from)

Try to check this:

Please note that there is an error in his code, you can se my correction to the code in danish but you will get it.

thank you very much. you're a life saver.

but since i'm a noob i don't get something:

the wire that goes from the pin between the 1 pin and 12 pin goes to the ground too?

and let me see if i understand :

  1. the common in the middle goes to the analog pin input
  2. the last pin on the rotary switch goes to 5v
  3. the first pin on the rotary switch goes to ground

am i right?

thanks