View
3.132
Download
3
Category
Preview:
Citation preview
OBJETIVOS
• Trabajar con salidas digitales
• Desarrollar nuestro primer programa escrito
• Controlar LED RGB
• Trabajar con estructuras de control for
• Comprender la diferencia entre legibilidad y
funcionalidad
Ideas Previas:
• ¿Cómo funciona un semáforo?
• ¿Cuántos estados tiene?
• ¿Qué podemos añadirle usando sólo salidas
digitales?
INTRODUCCIÓN
• ARDUINO BASIC SHIELD
• SALIDAS DIGITALES
• ESQUEMA LED RGB
• COLORES RGB
• ESTRUCTURA FOR
• PROGRAMA MODIFICAR
INFORMACIÓN
SALIDAS DIGITALES Hay que declararlas en el set up
Podemos escribir 5v ó 0v en el pin digital de salida
ESTRUCTURA DE CONTROL FOR
Se usa para repetir las sentencias entre los corchetes for (int i=0; i<10; i++){// sentencias que queremos repetir
}
Realizar un semáforo 10s verde, 2s amarillo, 5s rojo
• Completar el programa anterior
• Simplificar el código
• Añadir parpadeo de 0,2s a la luz amarilla
• Usar for para la repetición
• Añadir timbre, que puede sonar al unísono con la luz
amarilla parpadeante
• Reducir el tiempo de parpadeo en cada bucle
HACER
Este guía se distribuye bajo licencia Reconocimiento-‐ ComparMrIgual CreaMve commons 4.0
(cc) 2014 José Pujol Pérez Some rights reserved. This work licensed under CreaMve Commons AXribuMon-‐ShareAlike License. To view a copy of full license, see
hXp://creaMvecommons.org/licenses/by-‐sa/3.0/ or write to CreaMve Commons, 559 Nathan AbboX Way, Stanford, California 94305, USA.
Some of the figures have been taken from the Internet Source, and author and licence if known, is specified.
For those images, fair use applies.
licencia
Recommended