-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpresentation.tex
191 lines (170 loc) · 5.16 KB
/
presentation.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
\documentclass{beamer}
%%%%%%%%%%%%%%%%%%%%---Pacotes Usados---%%%%%%%%%%%%%%%%%%
\usepackage{xcolor}
\usepackage[latin1]{inputenc}
\usepackage[brazil]{babel}
\usepackage{graphicx}
%\usepackage[utf8]{inputenc}
\usepackage{float}
%http://www.tex.ac.uk/FAQ-RCS.html
\usepackage{svn}
\usepackage{listings}
%%%%%%%%%%%%%%%%%%%%%%---TEMA---%%%%%%%%%%%%%%%%%%%%%
\usetheme{Berlin}
\definecolor{mygrey}{RGB}{66, 66, 66}
\setbeamertemplate{blocks}[rounded][shadow=false]
\addtobeamertemplate{block begin}{\pgfsetfillopacity{0.8}}{\pgfsetfillopacity{1}}
\setbeamercolor{structure}{fg=mygrey}
\setbeamercolor{block title example}{fg=blue!50,bg= blue!10}
\setbeamercolor{block body example}{fg= blue,bg= blue!5}
\lstset{
language=C++,
basicstyle=\tiny,
keywordstyle=\color{blue}\ttfamily,
stringstyle=\color{red}\ttfamily,
commentstyle=\color{green}\ttfamily,
breaklines=true
}
%%%%%%%%%%%%%%%%%%%%---Informações Iniciais---%%%%%%%%%%%%%%%%%%
\title[Arduino Day]{Instrumentação com Arduino:\\ Função Millis() e Buffer Circular}
\author{Gustavo Henrique Leal}
\institute{IDEIA - PUCRS}
\date{\today}
%%%%%%%%%%%%%%%%%%%%---Inicio do Documento---%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%---CAPA---%%%%%%%%%%%%%%%%%%
\begin{frame}<beamer>
\titlepage
\end{frame}
%%%%%%%%%%%%%%%%%%%%---Introdução---%%%%%%%%%%%%%%%%%%
%\section{Introdução}
\begin{frame}{Introdução}
\begin{itemize}
\item Instrumentação no Arduino
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%---Millis()---%%%%%%%%%%%%%%%%%%
\section{Millis()}
\subsection{Delay()}
%\usebackgroundtemplate{\includegraphics[width=0.5\articlewidth]{images/clock.jpeg}}
%%%%%%%%%%%%%%%%%%%%---Delay()---%%%%%%%%%%%%%%%%%%
\begin{frame}{Delay()}
\begin{itemize}
\item O que é
\item Como usar
\item Desvantagens
\end{itemize}
% \begin{figure}
% \includegraphics[width=\textwidth]{images/clock.jpeg}
% \end{figure}
\end{frame}
%\usebackgroundtemplate{\includegraphics[width=\paperwidth]{}}
\begin{frame}[fragile]
\textbf{Exemplo:}
\begin{lstlisting}
void setup() {
pinMode(7, OUTPUT);
pinMode(3, OUTPUT);
}
void loop() {
digitalWrite(7, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(7, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
digitalWrite(3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(2000); // wait for a second
digitalWrite(3, LOW); // turn the LED off by making the voltage LOW
delay(2000); // wait for a second
}
\end{lstlisting}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ---MIllis()---%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Millis}
\begin{itemize}
\item Funcionamento;
\item Vantagens;
\item Desvantagens.
\end{itemize}
\end{frame}
\begin{frame}[fragile]
\begin{lstlisting}
unsigned long lastTimeLed1 = 0;
unsigned long lastTimeLed2 = 0;
int ledState = LOW;
int led2State = LOW;
void setup() {
pinMode(3, OUTPUT);
pinMode(7, OUTPUT);
}
void loop() {
if( millis() - lastTimeLed1 > 1000){
lastTimeLed1 = millis();
if(ledState == LOW){
ledState = HIGH;
} else {
ledState = LOW;
}
digitalWrite(3, ledState);
}
if( millis() - lastTimeLed2 > 2000){
lastTimeLed2 = millis();
if(led2State == LOW){
led2State = HIGH;
} else {
led2State = LOW;
}
digitalWrite(7, led2State);
}
}
\end{lstlisting}
\end{frame}
%%%%%%%%%%%%%%%%%%%%---BUFFER CIRCULAR()---%%%%%%%%%%%%%%%%%%
\section{Buffer circular}
\begin{frame}{Buffer circular}
\begin{itemize}
\item O que é um buffer?
\item LIFO
\item Aplicações
\item Vantagens
\end{itemize}
\end{frame}
\begin{frame}{Buffer Circular}
\begin{itemize}
\item Buffer circular
\item FIFO
\item Aplicações:
\begin{itemize}
\item Um processo para outro;
\item Múltiplos processos para um;
\item Um processo para múltiplos.
\end{itemize}
\end{itemize}
%%%%%%%%%%%%%%%%%%%%%Adicionar imagem de buffer circular
\end{frame}
\begin{frame}[fragile]
\textbf{Exemplo: }
\begin{lstlisting}
#define BUFFERSIZE 100
int bufferCircular[BUFFERSIZE];
int posicao = 0;
float mediaDoBuffer(){
unsigned long somatorio = 0;
for (int i = 0; i < BUFFERSIZE; i++)
somatorio = somatorio + bufferCircular[i];
//Serial.println(somatorio);
return (double) somatorio / BUFFERSIZE;
}
void setup(){
Serial.begin(9600);
for (int i = 0; i < BUFFERSIZE; i++)
bufferCircular[i] = 0;
}
void loop(){
bufferCircular[posicao] = analogRead(A5);
posicao = (posicao + 1) % BUFFERSIZE;
mediaDoBuffer();
Serial.println(mediaDoBuffer(), 4);
}
\end{lstlisting}
\end{frame}
\end{document}