Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I've been playing around with circuitikz, and am really loving it so far. The only problem is that I really don't know how to adapt it when there a symbol that I want is not present.

For example, I would like to draw the following circuit:

A circuit

The specific problem that I am having is that I don't know how to terminate both ends with a +5V and -5V symbol. This is the best that I could come up with:

\documentclass{article}
\usepackage[american voltages,siunitx]{circuitikz}
\begin{document}
\begin{circuitikz}
   \draw (0,0) to [battery,l=\SI{-5}{V}] (0,0)
               to [empty led,l=LED1] (0,3)
               to [R=\SI{510}{\ohm}] (0,5)
               to [battery,l=\SI{5}{V}] (0,5);               
    \end{circuitikz}
\end{document}

Another related question: How do I flip the LED direction in the code above without starting from the top (0,5) and going to (0,0)? I tried something like [empty led,l<=LED1] but that didn't work.

Thank you for any advice or suggestions!

share|improve this question

1 Answer 1

up vote 3 down vote accepted

circuitikz uses tikz, so you can use the usual tikz constructs (such as \draw). Here's a simple version of the code producing what you need (of course, feel free to improve it according to your needs):

\documentclass{article}
\usepackage[american voltages,siunitx]{circuitikz}
\begin{document}

\begin{circuitikz}
   \draw (0,5) to [R={\parbox{1cm}{R1\\\SI{510}{\ohm}}}] (0,3)
               to [empty led,l=LED1] (0,0);
  \draw (-0.5,0) -- node[anchor=north,align=center] {\SI{-5}{V}  \\ IR-LED } (0.5,0);
  \draw (-0.5,5) --  node[anchor=south] {VCC} (0.5,5)  node[anchor=west] {\SI{5}{V}};
\end{circuitikz}

\end{document}

enter image description here

Following a suggestion by Harish Kumar, you can flip the LED direction by interchanging its coordinates:

\documentclass{article}
\usepackage[american voltages,siunitx]{circuitikz}

\begin{document}

\begin{circuitikz}
   \draw (0,3) to [empty led,l=LED]  (0,0);  
   \draw (0,3) to  [R={\parbox{1cm}{R1\\\SI{510}{\ohm}}}, mirror] (0,5);
  \draw (-0.5,0) -- node[anchor=north,align=center] {\SI{-5}{V}  \\ IR-LED } (0.5,0);
  \draw (-0.5,5) --  node[anchor=south] {VCC} (0.5,5)  node[anchor=west] {\SI{5}{V}};
\end{circuitikz}

\end{document}

enter image description here

share|improve this answer
    
To flip the direction of LED, just interchange the co-ordinates. \draw (0,0) to [empty led,l=LED1] (0,3); to \draw (0,3) to [empty led,l=LED1] (0,0); –  Harish Kumar Mar 12 '12 at 23:38
    
@HarishKumar: thanks! I've updated my answer with your suggestion. –  Gonzalo Medina Mar 12 '12 at 23:45
    
It should be \draw (0,0) to [empty led,l=LED1] (0,3); in the first line to flip the direction of LED in your second code. –  Harish Kumar Mar 13 '12 at 0:35
    
Forgive me for editing your answer @Gonzalomedina. Did I edit properly? –  Harish Kumar Mar 13 '12 at 0:42
    
@HarishKumar: no problem; you can freely edit ;-) However, I think the OP originally had the LED pointing as in your edit but wanted it flipped the other way around (as in my first example code)? –  Gonzalo Medina Mar 13 '12 at 1:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.