\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Byron} \pdfinfo{ /Title (programacion-en-arduino.pdf) /Creator (Cheatography) /Author (Byron) /Subject (Programación en Arduino Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{000000} \definecolor{LightBackground}{HTML}{F7F7F7} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Programación en Arduino Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Byron} via \textcolor{DarkBackground}{\uline{cheatography.com/122873/cs/22999/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Byron \\ \uline{cheatography.com/byron} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 25th May, 2020.\\ Updated 26th May, 2020.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{4} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Datos}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{3.833cm}}{{\bf{Nombre:}} SOBERANIS CEDILLO BRYAN FERNANDO} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{{\bf{Matrícula:}} 1253408} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{3.833cm}}{{\bf{Fecha:}} 25/05/2020} \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Sensor}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{Dispositivo que capta magnitudes físicas (variaciones de luz, temperatura, sonido, etc.) u otras alteraciones de su entorno.% Row Count 3 (+ 3) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Sensor de temperatura LM35}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{3.833cm}}{float leerGradosC()\{ \newline int dato; \newline float c; \newline //leemos los datos analógicos del sensor \newline dato = analogRead(A0); \newline //convertimos el dato de entrada en grados C \newline C = (500.0 * dato/1024); \newline return C; \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Sensor Ultrasonico HC-SR04}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{3.833cm}}{int trigPin = 8; \newline int echoPin = 9; \newline long duration; //tiempo de ida/vuelta \newline int cm = 0; \newline \newline void setup()\{ \newline Serial.begin(9600); \newline pinMode(trigPin, OUTPUT); \newline pinMode(echoPin, INPUT); \newline \} \newline \newline void loop()\{ \newline digitalwrite(trigPin, LOW); \newline delayMicroseconds(2); \newline \newline digitalwrite(trigPin, HIGH); \newline delayMicroseconds(10); \newline digitalwrite(trigPin, LOW); \newline \newline duration = pulseIn(echoPin, HIGH); \newline \newline duration = duration/2; \newline cm=duration/29; \newline Serial.print("Distancia: "); \newline Serial.println(cm); \newline delay(100); \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Sensor IR LM393 (detector de obstáculos)}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{3.833cm}}{const int sensorPin = 9; \newline \newline void setup()\{ \newline Serial.begin(9600); //iniciar puerto serie \newline pinMode(sensorPin, INPUT); //definir pin como entrada \newline \} \newline \newline void loop()\{ \newline int value = 0; \newline value = digitalRead(sensorPin); //lectura digital de pin \newline \newline if (value==HIGH)\{ \newline Serial.println("se detecto el obstáculo"); \newline \} \newline delay(1000); \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Sensor de humedad FC-28}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{3.833cm}}{const int sensorPin = 10; \newline \newline void setup() \newline \{ \newline Serial.begin(9600); \newline pinMode(sensorPin,INPUT); \newline \} \newline \newline void loop() \newline \{ \newline int humedad = digitalRead(sensorPin); \newline \newline //mandar mensaje a puerto serie en función del valor leído \newline if (humedad == HIGH) \newline \{ \newline Serial.println("encendido"); \newline //aquí se ejecutarían las acciones \newline \} \newline delay(1000); \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Sensor de movimiento PIR}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{3.833cm}}{const int LEDPin = 13; \newline const int PIRPin = 2; \newline \newline void setup() \newline \{ \newline pinMode(LEDPin, OUTPUT); \newline pinMode(PIRPin, INPUT); \newline \} \newline \newline void loop() \newline \{ \newline int value= digitalRead(PIRPin); \newline \newline if (value == HIGH) \newline \{ \newline digitalWrite(LEDPin, HIGH); \newline delay(50); \newline digitalWrite(LEDPin, LOW); \newline delay(50); \newline \} \newline else \newline \{ \newline digitalWrite(LEDPin, LOW); \newline \} \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Bluetooth}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{Bluetooth es una especificación industrial para Redes inalámbricas de Área Personal (WPAN) que posibilita la transmisión de voz y datos entre diferentes dispositivos mediante un enlace por radiofrecuencia en la banda ISM de los 2.4 GHz.% Row Count 5 (+ 5) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Conexión Bluetooth}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{3.833cm}}{const int led = 13; \newline \newline int option; \newline \newline void setup()\{ \newline Serial.begin(9600); \newline pinMode(led, OUTPUT); \newline \} \newline \newline void loop()\{ \newline //si existe información pendiente \newline if (serial.available()\textgreater{}0)\{ \newline //leemos la opción \newline char option = Serial.read(); \newline \{ \newline //si la opción esta entre "1" y "9" \newline if (option \textgreater{}= "1" \&\& option \textless{}= "9") \newline \{ \newline //restamos el valor "0" para obtener el numero enviado \newline option -* "0"; \newline for(Int i=0;i\textless{}option;i++)\{ \newline digitalWrite(led, HIGH); \newline delay(100); \newline digitalWrite(led, LOW); \newline delay(200); \newline \} \newline \} \newline \} \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Internet de las cosas}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{El internet de las cosas es un concepto que se refiere a una interconexión digital de objetos cotidianos con internet.% Row Count 3 (+ 3) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Pasos para LoT en Arduino}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{*Conseguir una Ethernet Shield compatible con Arduino UNO. \newline % Row Count 2 (+ 2) *Crear una base de datos. \newline % Row Count 3 (+ 1) *Programar un servidor. \newline % Row Count 4 (+ 1) *Programar la tarjeta Arduino.% Row Count 5 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Ejemplo IoT}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{3.833cm}}{{\emph{include \textless{}Ethernet.h\textgreater{} \newline }}include \textless{}SPI.h\textgreater{} \newline \newline //configuración del ethernet shield \newline byte mac{[}{]} = \{exDE, exAD, exBE, exEF, exFF, exEE\}; //dirección MAC \newline byte ip{[}{]} = \{192,168,1,100\}; // Dirección IP del Arduino \newline byte server{[}{]} = \{192,168,1,6\}; // Dirección IP del servidor \newline EthernetClient client; \newline float temperatura; \newline int analog\_pin = 0; \newline \newline void setup(void) \{ \newline Ethernet.begin(mac, ip); //Inicializamos el ethernet shield \newline delay(1000); // Esperamos 1 segundo de cortesía \newline \} \newline \newline void loop(void)\{ \newline temperatura = analogRead(analog\_pin); \newline temperatura = \seqsplit{S.0temperatura100.0/1024.0;} \newline //Display in serial monitor \newline Serial.print(temperatura); //Return temperature to Monitor \newline Serial.println( "oC"); \newline //Proceso de envío de muestras al servidor \newline Serial \seqsplit{println("Connecting...");} \newline if (client.connect(server, s0)\textgreater{}0)\{ \newline // conexión con el servidor \newline client.print("GET \seqsplit{/tutoiot/iot.php?valor=");} //Enviamos los datos por GET \newline client.print(temperatura); \newline client.println("HTTP/1.0"); \newline client.println("User-Agent: Arduino 1.0"); \newline client.println(); \newline Serial.println("Conectado"); \newline \} else \{ \newline Serial.println("fallo en la conexión"); \newline \} \newline if (!client.connected())\{ \newline Serial.println("Disconnected"); \newline \} \newline client.stop(); \newline client.flush(); \newline delay(6000); //espero un minuto antes de tomar otra muestra \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}