I need to represent a circuit containing Arduino. I'm new to circuitikz, and to latex, so I'm not able to code a complex circuit component.
-
Welcome to the site. Can you help us by focusing your question a bit, and providing some code to show us what you have tried? – Steven B. Segletes Feb 15 '19 at 12:06
2 Answers
I think there's no package for that, but you can create your own Arduino Uno component. I would recommend you to read CircuiTikZ Manual: https://texdoc.org/serve/circuitikzmanual.pdf/0, and read about LaTeX too (there're many online resources for that, just search in google).
After that, in order to create your own component, I would recommend you to check out John Kormylo's answer in here: CircuiTikZ — create new component. Following his Multipole Tutorial I was able to create this Arduino Uno Diagram for blinking a LED:
This is the code:
\documentclass[margin=3mm]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[american, siunitx]{circuitikz}
\pgfdeclareshape{arduno}{
\anchor{center}{\pgfpointorigin} % within the node, (0,0) is the center
\anchor{text} % this is used to center the text in the node
{\pgfpoint{-.5\wd\pgfnodeparttextbox}{-.5\ht\pgfnodeparttextbox}}
% Pin Assignments
\savedanchor\ardunoa{\pgfpoint{-2.4cm}{-3.5cm}} % Pin A5
\anchor{A5}{\ardunoa}
\savedanchor\ardunob{\pgfpoint{-2.4cm}{-3cm}} % Pin A4
\anchor{A4}{\ardunob}
\savedanchor\ardunoc{\pgfpoint{-2.4cm}{-2.5cm}} % Pin A3
\anchor{A3}{\ardunoc}
\savedanchor\ardunod{\pgfpoint{-2.4cm}{-2cm}} % Pin A2
\anchor{A2}{\ardunod}
\savedanchor\ardunoe{\pgfpoint{-2.4cm}{-1.5cm}} % Pin A1
\anchor{A1}{\ardunoe}
\savedanchor\ardunof{\pgfpoint{-2.4cm}{-1cm}} % Pin A0
\anchor{A0}{\ardunof}
\savedanchor\ardunog{\pgfpoint{2.4cm}{-3.5cm}} % Pin D0
\anchor{D0}{\ardunog}
\savedanchor\ardunoh{\pgfpoint{2.4cm}{-3cm}} % Pin D1
\anchor{D1}{\ardunoh}
\savedanchor\ardunoi{\pgfpoint{2.4cm}{-2.5cm}} % Pin D2
\anchor{D2}{\ardunoi}
\savedanchor\ardunoj{\pgfpoint{2.4cm}{-2cm}} % Pin D3
\anchor{D3}{\ardunoj}
\savedanchor\ardunok{\pgfpoint{2.4cm}{-1.5cm}} % Pin D4
\anchor{D4}{\ardunok}
\savedanchor\ardunol{\pgfpoint{2.4cm}{-1cm}} % Pin D5
\anchor{D5}{\ardunol}
\savedanchor\ardunom{\pgfpoint{2.4cm}{-0.5cm}} % Pin D6
\anchor{D6}{\ardunom}
\savedanchor\ardunon{\pgfpoint{2.4cm}{0cm}} % Pin D7
\anchor{D7}{\ardunon}
\savedanchor\ardunoo{\pgfpoint{2.4cm}{0.5cm}} % Pin D8
\anchor{D8}{\ardunoo}
\savedanchor\ardunop{\pgfpoint{2.4cm}{1cm}} % Pin D9
\anchor{D9}{\ardunop}
\savedanchor\ardunoq{\pgfpoint{2.4cm}{1.5cm}} % Pin D10
\anchor{D10}{\ardunoq}
\savedanchor\ardunor{\pgfpoint{2.4cm}{2cm}} % Pin D11
\anchor{D11}{\ardunor}
\savedanchor\ardunos{\pgfpoint{2.4cm}{2.5cm}} % Pin D12
\anchor{D12}{\ardunos}
\savedanchor\ardunot{\pgfpoint{2.4cm}{3cm}} % Pin D13
\anchor{D13}{\ardunot}
\savedanchor\ardunou{\pgfpoint{-2.4cm}{2.5cm}} % Pin AREF
\anchor{AREF}{\ardunou}
\savedanchor\ardunov{\pgfpoint{-2.4cm}{3cm}} % Pin RST
\anchor{RST}{\ardunov}
\savedanchor\ardunow{\pgfpoint{0.1cm}{-4.4cm}} % Pin GND
\anchor{GND}{\ardunow}
\savedanchor\ardunox{\pgfpoint{-1cm}{4.4cm}} % Pin 3V
\anchor{3V}{\ardunox}
\savedanchor\ardunoy{\pgfpoint{-0.5cm}{4.4cm}} % Pin 5V
\anchor{5V}{\ardunoy}
\savedanchor\ardunoz{\pgfpoint{1cm}{4.4cm}} % Pin Vin
\anchor{VIN}{\ardunoz}
\foregroundpath{ % Border and Pin Names are drawn here
% Container
\pgfsetlinewidth{0.5pt}
\pgfpathrectanglecorners{\pgfpoint{2cm}{4cm}}{\pgfpoint{-2cm}{-4cm}}
\pgfusepath{draw}
% Analog Input Pins
\pgfsetlinewidth{0.9pt}
\pgfpathmoveto{\pgfpoint{-2cm}{-3.5cm}}
\pgfpathlineto{\pgfpoint{-2.4cm}{-3.5cm}}
\pgfpathmoveto{\pgfpoint{-2cm}{-3cm}}
\pgfpathlineto{\pgfpoint{-2.4cm}{-3cm}}
\pgfpathmoveto{\pgfpoint{-2cm}{-2.5cm}}
\pgfpathlineto{\pgfpoint{-2.4cm}{-2.5cm}}
\pgfpathmoveto{\pgfpoint{-2cm}{-2cm}}
\pgfpathlineto{\pgfpoint{-2.4cm}{-2cm}}
\pgfpathmoveto{\pgfpoint{-2cm}{-1.5cm}}
\pgfpathlineto{\pgfpoint{-2.4cm}{-1.5cm}}
\pgfpathmoveto{\pgfpoint{-2cm}{-1cm}}
\pgfpathlineto{\pgfpoint{-2.4cm}{-1cm}}
\pgfusepath{draw}
% Digital Input/Output Pins
\pgfpathmoveto{\pgfpoint{2cm}{-3.5cm}}
\pgfpathlineto{\pgfpoint{2.4cm}{-3.5cm}}
\pgfpathmoveto{\pgfpoint{2cm}{-3cm}}
\pgfpathlineto{\pgfpoint{2.4cm}{-3cm}}
\pgfpathmoveto{\pgfpoint{2cm}{-2.5cm}}
\pgfpathlineto{\pgfpoint{2.4cm}{-2.5cm}}
\pgfpathmoveto{\pgfpoint{2cm}{-2cm}}
\pgfpathlineto{\pgfpoint{2.4cm}{-2cm}}
\pgfpathmoveto{\pgfpoint{2cm}{-1.5cm}}
\pgfpathlineto{\pgfpoint{2.4cm}{-1.5cm}}
\pgfpathmoveto{\pgfpoint{2cm}{-1cm}}
\pgfpathlineto{\pgfpoint{2.4cm}{-1cm}}
\pgfpathmoveto{\pgfpoint{2cm}{-0.5cm}}
\pgfpathlineto{\pgfpoint{2.4cm}{-0.5cm}}
\pgfpathmoveto{\pgfpoint{2cm}{0cm}}
\pgfpathlineto{\pgfpoint{2.4cm}{0cm}}
\pgfpathmoveto{\pgfpoint{2cm}{0.5cm}}
\pgfpathlineto{\pgfpoint{2.4cm}{0.5cm}}
\pgfpathmoveto{\pgfpoint{2cm}{1cm}}
\pgfpathlineto{\pgfpoint{2.4cm}{1cm}}
\pgfpathmoveto{\pgfpoint{2cm}{1.5cm}}
\pgfpathlineto{\pgfpoint{2.4cm}{1.5cm}}
\pgfpathmoveto{\pgfpoint{2cm}{2cm}}
\pgfpathlineto{\pgfpoint{2.4cm}{2cm}}
\pgfpathmoveto{\pgfpoint{2cm}{2.5cm}}
\pgfpathlineto{\pgfpoint{2.4cm}{2.5cm}}
\pgfpathmoveto{\pgfpoint{2cm}{3cm}}
\pgfpathlineto{\pgfpoint{2.4cm}{3cm}}
\pgfusepath{draw}
% AREF, RST Pins
\pgfpathmoveto{\pgfpoint{-2cm}{2.5cm}}
\pgfpathlineto{\pgfpoint{-2.4cm}{2.5cm}}
\pgfpathmoveto{\pgfpoint{-2cm}{3cm}}
\pgfpathlineto{\pgfpoint{-2.4cm}{3cm}}
\pgfusepath{draw}
% GND Pin
\pgfpathmoveto{\pgfpoint{0.1cm}{-4cm}}
\pgfpathlineto{\pgfpoint{0.1cm}{-4.4cm}}
\pgfusepath{draw}
% Power Pins
\pgfpathmoveto{\pgfpoint{-1cm}{4cm}}
\pgfpathlineto{\pgfpoint{-1cm}{4.4cm}}
\pgfpathmoveto{\pgfpoint{-0.5cm}{4cm}}
\pgfpathlineto{\pgfpoint{-0.5cm}{4.4cm}}
\pgfpathmoveto{\pgfpoint{1cm}{4cm}}
\pgfpathlineto{\pgfpoint{1cm}{4.4cm}}
\pgfusepath{draw}
% Arduino UNO Board Name
\pgftext[bottom,at={\pgfpoint{0cm}{1.6cm}}]{\normalsize Arduino}
\pgftext[bottom,at={\pgfpoint{-0.25cm}{1.15cm}}]{\normalsize UNO}
% Analog Input Pin Names
\pgftext[bottom,rotate=-90,at={\pgfpoint{2.3cm}{-1.3cm}}]{\footnotesize Analog Input}
\pgftext[center,at={\pgfpoint{-1.6cm}{-3.5cm}}]{\footnotesize A5}
\pgftext[center,at={\pgfpoint{-1.6cm}{-3cm}}]{\footnotesize A4}
\pgftext[center,at={\pgfpoint{-1.6cm}{-2.5cm}}]{\footnotesize A3}
\pgftext[center,at={\pgfpoint{-1.6cm}{-2cm}}]{\footnotesize A2}
\pgftext[center,at={\pgfpoint{-1.6cm}{-1.5cm}}]{\footnotesize A1}
\pgftext[center,at={\pgfpoint{-1.6cm}{-1cm}}]{\footnotesize A0}
% Digital Input/Output Pin Names
\pgftext[bottom,rotate=90,at={\pgfpoint{-0.3cm}{-1.3cm}}]{\footnotesize Digital Input/Output}
\pgftext[center,at={\pgfpoint{1.6cm}{-3.5cm}}]{\footnotesize D0}
\pgftext[center,at={\pgfpoint{1.6cm}{-3cm}}]{\footnotesize D1}
\pgftext[center,at={\pgfpoint{1.6cm}{-2.5cm}}]{\footnotesize D2}
\pgftext[center,at={\pgfpoint{1.6cm}{-2cm}}]{\footnotesize D3}
\pgftext[center,at={\pgfpoint{1.6cm}{-1.5cm}}]{\footnotesize D4}
\pgftext[center,at={\pgfpoint{1.6cm}{-1cm}}]{\footnotesize D5}
\pgftext[center,at={\pgfpoint{1.6cm}{-0.5cm}}]{\footnotesize D6}
\pgftext[center,at={\pgfpoint{1.6cm}{0cm}}]{\footnotesize D7}
\pgftext[center,at={\pgfpoint{1.6cm}{0.5cm}}]{\footnotesize D8}
\pgftext[center,at={\pgfpoint{1.6cm}{1cm}}]{\footnotesize D9}
\pgftext[center,at={\pgfpoint{1.6cm}{1.5cm}}]{\footnotesize D10}
\pgftext[center,at={\pgfpoint{1.6cm}{2cm}}]{\footnotesize D11}
\pgftext[center,at={\pgfpoint{1.6cm}{2.5cm}}]{\footnotesize D12}
\pgftext[center,at={\pgfpoint{1.6cm}{3cm}}]{\footnotesize D13}
% RST, AREF Pin Names
\pgftext[center,at={\pgfpoint{-1.5cm}{2.5cm}}]{\footnotesize AREF}
\pgftext[center,at={\pgfpoint{-1.6cm}{3cm}}]{\footnotesize RST}
% GND Pin Name
\pgftext[top,at={\pgfpoint{0.1cm}{-3.6cm}}]{\footnotesize GND}
% Power Pin Names
\pgftext[top,at={\pgfpoint{0.1cm}{3.5cm}}]{\small Power}
\pgftext[top,at={\pgfpoint{-1cm}{3.8cm}}]{\footnotesize 3V}
\pgftext[top,at={\pgfpoint{-0.5cm}{3.8cm}}]{\footnotesize 5V}
\pgftext[top,at={\pgfpoint{1cm}{3.8cm}}]{\footnotesize Vin}
}
}
\begin{document}
\begin{tikzpicture}
\draw
(2,4) node[arduno] (arduno1) {}
(arduno1.D13) to(6,7) to [R](6,3) to [leDo](6,-0.9)
(arduno1.GND) to(2.1,-0.9) to (6,-0.9)
;
\node[align=left] at (7,5) {220 $\Omega$ \\ Resistor};
\node[align=left] at (7.2,1) {LED};
\end{tikzpicture}
\end{document}
You don't have to create an exact physical represantation of an Arduino Uno if you don't want to, as long as you represent its pins in an understandable way it's fair enough. Either way, any suggestions on how to improve the aesthetics of my diagram (or my code) are welcomed
- 265
As a starting point, you can use the following code (It is not complete code for Arduino Uno and some components are not scaled).
\documentclass[margin=5mm]{standalone}
\usepackage{xcolor,circuitikz,tikz}
\usetikzlibrary{calc,intersections,positioning}
\definecolor{darkcerulean}{rgb}{0.03, 0.27, 0.49}
\tikzset{%
myarduino/.pic={
\coordinate (A) at (0,0);
\filldraw[very thick, darkcerulean] (A)--(66.1,0)-|(66.1,2.5)--++(45:2.5)--++(90:30)--++(135:2.5)--++(90:16)--++(180:66.1)--cycle;
\filldraw[very thick,gray!40](-2.5,3) rectangle (10,10);
\filldraw[very thick,gray!40](-6,40) rectangle (10,50);
\filldraw[very thick,gray](25,13) rectangle (63,20);
\foreach \x/\t in {26/RESET,29/3V3,32/5V,35/GND1,38/GND2,41/VIN}{
\node (\t) at (\x,3mm) [fill,draw,minimum width=3mm,minimum height=3mm]{};
\node at (\x,5mm) [xshift=2.5mm,above=8mm,rotate=90]{$\mathbf{\t}$};}
\foreach \x/\n in {46/0,49/1,52/2,55/3,58/4,61/5}{
\node (\n) at (\x,3mm) [fill,draw,minimum width=3mm,minimum height=3mm]{};
\node at (\x,3mm) [above=3mm]{$\mathbf{\n}$};}
}
}
\begin{document}
\begin{tikzpicture}[x=2mm,y=2mm]
\pic at (0,0) {myarduino};
\draw[very thick] (GND1)--++(-90:10);
\draw[very thick] (RESET)--++(-90:10);
\draw[very thick] (1)--++(-90:10);
\draw[very thick] (4)--++(-90:10);
\end{tikzpicture}
\end{document}

