[Tex/LaTex] Multi way switch in circuitikz

circuitikzsymbols

I wonder whether there is a symbol of a sort of multi-way switch in circuitikz. That is to say a switch like the "spdt" (single-pole-double-throw), but with more switching positions. I need something like nine positions for the following circuit.

enter image description here

Best Answer

This is one possible solution where for repeated nodes generation and wire connections, several foreach commands are used. A style called dot with two arguments is defined for the rotary switch so that an internal label is added for ease of wiring. #1 = locations, #2 = label.

enter image description here

Code

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{shapes,positioning,decorations.markings}
\usepackage{circuitikz}

\begin{document}
\tikzset{dot/.style args={#1#2}{decoration={
  markings,  mark=at position #1 with 
  {\draw[thin,black,fill=white] circle (1pt)coordinate(#2){};}}
  ,preaction={decorate}
  }} 

\begin{circuitikz}
% black dots on the left
\path [postaction={decorate,decoration={markings,
 mark=between positions 0 and 1 step 0.125 with 
{\draw[thin,black,fill=black] circle (1pt);}}}] (0,1) -- (0,-1);

% rotary switch on the right
\foreach \p/\l in{0/1,0.125/2,0.25/3,0.375/4,0.5/5,
0.625/6,0.750/7,0.875/8,0.99/9}{
\path [dot={\p}{a\l}] (1,0.5) to [out=180, in=180,looseness=1.5] (1,-0.5);
}

% pointer
\draw[->,red] (1,0) -- (0.65,0.15);  
\draw (1,0) to[short,*-o] (1.5,0)node(a){};
\draw(-0.5,1)node[below]{\tiny +}to[short,o-] (0,1);

% wires
\foreach \x\y in {1/1,0.75/2,0.5/3,0.25/4,0/5,
-0.25/6,-0.5/7,-0.75/8,-1/9} {
\draw[] (0,\x) --++(0.5,0) -- (a\y);
}
\draw(-0.5,-1)node[below]{\tiny $-$} to[short,o-] (0,-1);


\draw (0,1)--(0,-1);
\foreach \y in {0.875,0.625,0.375,0.125,-0.125,-0.375,-0.625,-0.875}{
\draw[gray] (-2pt,\y)--(2pt,\y);
}

% neutral wire
\draw (0,0) --(-0.8,0) --(-0.8,-1.5) to[short,-o](1.5,-1.5)node(b){};
\draw[->]  (a) --node[right](){\tiny Vac} (b);

% To remove the  overwriting lines
\foreach \p/\l in{0/1,0.125/2,0.25/3,0.375/4,0.5/5,
0.625/6,0.750/7,0.875/8,0.99/9}{
\path [dot={\p}{a\l}] (1,0.5) to [out=180, in=180,looseness=1.5] (1,-0.5);
}

\end{circuitikz}

\end{document}