将连接点添加到电路中的框

将连接点添加到电路中的框

我正在尝试使用 Circuitikz 构建一个简单的电路。我需要做的是,有一个盒子(代表一个模块),左侧有 2 个连接,右侧有 3 个连接。然后我需要将它与草图的其余部分连接起来。以下是我到目前为止尝试过的方法

\documentclass{article}

\usepackage{tikz}
\usepackage{circuitikz}



\begin{document}

\begin{figure}[h!]
    \begin{center}
        \begin{circuitikz} [scale = .6]
            \draw (-3,4)
            node[label={[font=\footnotesize]left:PWM Signal}] {};
            \draw (-3,8)
            node[label={[font=\footnotesize]left:Bela GND}] {};
            \node[draw,minimum width=1cm,minimum height=.8cm,anchor=south west] at (-5,6){Opt. Module};
            \draw(0,12)
            % to node[npn, photo, rotate=0, yscale=1]{} (0,12) % The phototransistor
            to[short] (2,12)
            to[R=$R_1$, *-] (2,10) % The resistor
            to[leDo] (2,8)
            to[leDo] (2,6)
            to[leDo] (2,4)
            to[leDo] (2,2)
            to[leDo] (2,0)
            to[short] (0,0);
            \draw(2,12)
            to[short, -*] (4,12) %zweite Reihe
            to[R=$R_2$,] (4,10)
            to[leDo] (4,8)
            to[leDo] (4,6)
            to[leDo] (4,4)
            to[leDo] (4,2)
            to[leDo] (4,0)
            to[short, *-*] (2,0);
            \draw(4,12)
            to[short, -*] (6,12) %dritte Reihe
            to[leDo] (6,10)
            to[leDo] (6,8)
            to[leDo] (6,6)
            to[leDo] (6,4)
            to[leDo] (6,2)
            to[leDo] (6,0)
            to[short, *-*] (4,0);
            \draw(6,12)
            to[short] (7,12);
            \draw (7,12)
            node[label={[font=\footnotesize]above:15V}] {};


        \end{circuitikz}
          \caption{Example of LED Circuit}
        \end{center}
    \end{figure}

\end{document}

答案1

有点像这样?

顺便说一句,我发现给空节点添加标签毫无意义。标签就是节点。另外,我改成了独立模式,因为我不需要以这种方式裁剪它。

\documentclass{standalone}
%\usepackage{tikz}% redundant
\usepackage{circuitikz}
\begin{document}
        \begin{circuitikz}[scale = .6]
          \begin{scope}[local bounding box=mybox]
            \draw (-3,4)
            node[left, font=\footnotesize] (bottom) {PWM Signal};
            \draw (-3,8)
            node[left,font=\footnotesize] (top) {Bela GND};
            \node[draw,minimum width=1cm,minimum height=.8cm,anchor=south west] (middle) at (-5,6){Opt. Module};
          \end{scope}
          \draw[thick] (mybox.south west) rectangle (mybox.north east);
          \draw (top -| mybox.west) -- ++(-2cm,0pt) node[ocirc] {};
          \draw (bottom -| mybox.west) -- ++(-2cm,0pt) node[ocirc] {};
          \draw (middle -| mybox.east) -- ++(2cm,0pt) node[ocirc] {};
          \draw (top -| mybox.east) -| (0,12);
          \draw (bottom -| mybox.east) -| (0,0);

            \draw(0,12)
            % to node[npn, photo, rotate=0, yscale=1]{} (0,12) % The phototransistor
            to[short] (2,12)
            to[R=$R_1$, *-] (2,10) % The resistor
            to[leDo] (2,8)
            to[leDo] (2,6)
            to[leDo] (2,4)
            to[leDo] (2,2)
            to[leDo] (2,0)
            to[short] (0,0);
            \draw(2,12)
            to[short, -*] (4,12) %zweite Reihe
            to[R=$R_2$,] (4,10)
            to[leDo] (4,8)
            to[leDo] (4,6)
            to[leDo] (4,4)
            to[leDo] (4,2)
            to[leDo] (4,0)
            to[short, *-*] (2,0);
            \draw(4,12)
            to[short, -*] (6,12) %dritte Reihe
            to[leDo] (6,10)
            to[leDo] (6,8)
            to[leDo] (6,6)
            to[leDo] (6,4)
            to[leDo] (6,2)
            to[leDo] (6,0)
            to[short, *-*] (4,0);
            \draw(6,12)
            to[short] (7,12);
            \draw (7,12)
            node[font=\footnotesize, above] {15V};
        \end{circuitikz}
\end{document}

演示

相关内容