-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
206 lines (192 loc) · 10.3 KB
/
index.html
File metadata and controls
206 lines (192 loc) · 10.3 KB
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<!doctype html>
<html lang="es">
<head>
<title>Robótica IES Lucas Mallada</title>
<meta charset="utf-8">
<link rel="stylesheet" href="styles.css">
<meta name="theme-color" content="#2163ce">
<script src="scripts.js"></script>
<link href="https://fonts.googleapis.com/css?family=Lato|Oswald|Source+Sans+Pro|Open+Sans|Raleway|Roboto|Roboto+Mono|Roboto+Condensed|Roboto+Slab" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script src="highlight/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body>
<header>
<div class="wrapper">
<a class="logo unselectable" href="#top"><b>ROBÓTICA LUCAS</b></a>
<nav id="navm">
<a href="#top">Inicio</a>
<a href="taller/sesiones/07.5/ultrasonidos.html">Sesión 07/05</a>
<a href="taller/sesiones/26.4/proyectos.html">Sesión 26/04</a>
<a href="#coche">¡Coche Inteligente!</a>
</nav>
</div>
</header>
<div class="main">
<div id="app_hacemos">
<h2 class="unselectable">Robótica IES Lucas Mallada<span class="intermitente">_</span></h2>
</div>
<div style="padding: 50px 200px">
<p style="font-size: 25px; font-family: Open Sans, Arial, Helvetica, sans-serif">
Apuntes del curso en el enlace de abajo, por si no recordáis algo.
</p>
<a class="centro opuesto" href="https://docs.google.com/document/d/1jadNavowYnB9FfNT0hcHKqV7fyJXKe4jlaOSAbSSSaw/edit?usp=sharing">
Acceder a los apuntes
<i class="material-icons">arrow_forward</i>
</a>
</div>
<div id="apps" class="contenido grid2col">
<!--h2 style="grid-column-start: 1; grid-column-end: 3; margin-top: 20px; margin-bottom: 30px">Ideas para la sesión de hoy</h2-->
<div style="background: rgb(39, 131, 216); grid-column-start: 1; grid-column-end: 3; ">
<h3>Acceder a la sesión del 07/05</h3>
<p>En esta sesión utilizamos el sensor de distancia por ultrasonidos HC-SR04.
</p>
<a class="centro" href="taller/sesiones/07.5/ultrasonidos.html">
¡Vamos allá!
<i class="material-icons">arrow_forward</i>
</a>
</div>
<div class="appL" style="background: #1FC04C;">
<h3>Acceder a la sesión del 26/04</h3>
<p>En esa sesión propusimos los siguientes proyectos:
</p>
<ul>
<li>Linterna electrónica</li>
<li>"Theremin", música que no se toca</li>
<li>Reloj de arena digital</li>
<li>Cruce de semáforos</li>
<li>Dado de la suerte electrónico</li>
<li>Música con Arduino</li>
</ul>
<a class="centro" href="taller/sesiones/26.4/proyectos.html">
Ir a la sesión
<i class="material-icons">arrow_forward</i>
</a>
</div>
<iframe style="grid-column: 2; height: 100%; width: 100%; border: 0" src="https://www.youtube.com/embed/K6KbEnGnymk?controls=2&rel=0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
<div class="appL" style="background: rgb(192, 103, 31);">
<h3>Música con los Buzzers</h3>
<p>El 30 de abril estuvimos utilizando los buzzers piezoeléctricos como unos altavoces con los que podíamos hacer música. <br>
Primero hicimos que tocara 2 notas, cada una durante 1 o 2 segundos, y después intentamos hacer algunas canciones. <br>
Algunos ejemplos fáciles que se suelen hacer son la canción de <i>Piratas del Caribe</i> o la de <i>Star Wars</i>, aunque se puede "traducir" cualquier partitura para ponerla en Arduino.
</p>
<a class="centro" href="https://www.prometec.net/buzzers/">
Acceder a un tutorial
<i class="material-icons">arrow_forward</i>
</a>
</div>
<div class="appR" style="background: rgb(3, 133, 194);">
<h3>Utilizando los Servomotores</h3>
<p>El viernes 3 de mayo aprendimos a usar los Servos, unos motores especiales que, en la mayoría de los casos, pueden girar en un ángulo de 180 grados. <br>
Tienen un funcionamiento distinto al de los motores normales, y en Arduino vienen incluidas unas funciones que nos ayudan a usarlo: <code>miServo.attach(PIN);</code> y <code>miServo.write(ÁNGULO);</code> <br>
Gracias a estas funciones, no necesitamos utilizar ninguna otra como <code>pinMode</code> o <code>analogWrite</code>, ya que el Arduino se encarga de hacer los cálculos para llevar al motor al ángulo que nosotros pongamos.
</p>
<a class="centro" href="https://gist.github.com/alexbertis/b9b9dc71c6b1f471a0cdd0e0a1b8c24c">
Ver el código
<i class="material-icons">arrow_forward</i>
</a>
</div>
</div>
</div>
<div id="coche" class="contenido">
<div id="el_circuito" style="padding: 20px 15%;">
<h2 class="espaciado">¿Cómo montamos el circuito?</h2>
<img src="images/coche.png" width="1000">
</div>
<div id="el_codigo" style="padding: 20px 15%;">
<h2 class="espaciado">¿Y el código?</h2>
<p class="cardview">Recordad que este código es el que hicimos el martes, que estaba basado en el del sensor ultrasonidos. Lo hemos reorganizado un poco.
</p>
<div class="cardview">
<p style="margin-bottom: 20px">Este es el código completo:</p>
<pre style="display: block"><code style="display: block;">
int recibePin = 10; // Echo Pin
int emitePin = 11; // Trigger Pin
int rMotorPin1 = 2; // DERECHO SENTIDO 1 (PINES DE LOS MOTORES)
int rMotorPin2 = 3; // DERECHO SENTIDO 2
int lMotorPin1 = 4; // IZQUIERDO SENTIDO 1
int lMotorPin2 = 5; // IZQUIERDO SENTIDO 2
float distancia; //Duración usada para calcular la distancia
void setup() {
// COMUNICAR CON EL ORDENADOR
Serial.begin(9600);
// SENSOR DE DISTANCIA
pinMode(emitePin, OUTPUT);
pinMode(recibePin, INPUT);
// TODOS LOS MOTORES COMO OUTPUT
pinMode(rMotorPin1, OUTPUT);
pinMode(rMotorPin2, OUTPUT);
pinMode(lMotorPin1, OUTPUT);
pinMode(lMotorPin2, OUTPUT);
}
void loop() {
distancia = medirDistancia(); // ABAJO HEMOS CREADO UNA "FUNCIÓN", COMO UNA CARPETA CON EL CÓDIGO
Serial.print(distancia); Serial.println(" centimetros");
if(distancia < 5){ // SI ESTÁ A MENOS DE 5 CM
retroceder();
delay(300);
girarIzquierda();
delay(300);
}else{
avanzar();
delay(50);
}
}
float medirDistancia(){
digitalWrite(emitePin, LOW);
delayMicroseconds(2);
digitalWrite(emitePin, HIGH);
delayMicroseconds(10);
digitalWrite(emitePin, LOW);
long duracion = pulseIn(recibePin, HIGH);
//Calcular la distancia (en cm) basada en la velocidad del sonido
float dist = duracion * (340.0 / 10000.0) / 2.0; // DIVIDIMOS 340 / 10000 AL PASAR DE METROS/SEGUNDO A CM/MICROSEGUNDO (340 * 100 / 1000000)
// Y LUEGO ENTRE 2 PARA PASAR DEL RECORRIDO DE IDA Y VUELTA A SOLO LA IDA
return dist;
}
void avanzar(){
digitalWrite(rMotorPin1, HIGH); // AVANZAR HACIA DELANTE ↑ ↑
digitalWrite(rMotorPin2, LOW); // ENCENDEMOS EL MISMO SENTIDO EN LOS DOS MOTORES | |
digitalWrite(lMotorPin1, HIGH); // GIRARÁN DE LA MISMA FORMA | |
digitalWrite(lMotorPin2, LOW); // TAMBIÉN APAGAMOS LOS SENTIDOS OPUESTOS ("LA MANGUERA")
}
void retroceder(){
digitalWrite(rMotorPin1, LOW); // RETROCEDER | |
digitalWrite(rMotorPin2, HIGH); // ENCENDEMOS EL MISMO SENTIDO EN LOS DOS MOTORES | |
digitalWrite(lMotorPin1, LOW); // GIRARÁN DE LA MISMA FORMA ↓ ↓
digitalWrite(lMotorPin2, HIGH); // TAMBIÉN APAGAMOS LOS SENTIDOS OPUESTOS ("LA MANGUERA")
}
void girarIzquierda(){
digitalWrite(rMotorPin1, HIGH); // GIRAR HACIA IZQUIERDA | ↑
digitalWrite(rMotorPin2, LOW); // EL DERECHO HACIA DELANTE | |
digitalWrite(lMotorPin1, LOW); // EL IZQUIERDO HACIA ATRÁS ↓ |
digitalWrite(lMotorPin2, HIGH);
}
void girarDerecha(){
digitalWrite(rMotorPin1, LOW); // GIRAR HACIA IZQUIERDA ↑ |
digitalWrite(rMotorPin2, HIGH); // EL DERECHO HACIA ATRÁS | |
digitalWrite(lMotorPin1, HIGH); // EL IZQUIERDO HACIA DELANTE | ↓
digitalWrite(lMotorPin2, LOW);
}
</code></pre>
</div>
</div>
</div>
<div id="contacto" class="contenido">
<h2 style="padding: 20px">Sube tu código de hoy</h2>
<div style="display: flex; margin-top: 10px">
<form action="https://formspree.io/alexberti02@gmail.com" method="POST">
<input type="text" name="name" placeholder="Nombre *" required>
<input type="email" name="_replyto" placeholder="Correo electrónico">
<textarea name="texto" placeholder="Mensaje o código *" class="codigo" required></textarea>
<input type="text" name="_gotcha" style="display:none" />
<input type="submit" value="Enviar">
</form>
</div>
</div>
<footer>
<p>© 2019</p>
</footer>
</body>
</html>