Top Banner
PRÁCTICAS DE PROGRAMACIÓN CON ARDUINO P2: SEMÁFORO José Pujol Pérez IES Vicente Aleixandre
14

P2: Arduino Basic Shield: Semáforo

Jul 17, 2015

Download

Education

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: P2: Arduino Basic Shield: Semáforo

PRÁCTICAS DE PROGRAMACIÓN CON ARDUINO

P2: SEMÁFORO

José  Pujol  Pérez  IES  Vicente  Aleixandre  

Page 2: P2: Arduino Basic Shield: Semáforo

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  

Page 3: P2: Arduino Basic Shield: Semáforo

Ideas Previas:

•  ¿Cómo funciona un semáforo?

•  ¿Cuántos estados tiene?

•  ¿Qué podemos añadirle usando sólo salidas

digitales?

 

INTRODUCCIÓN

Page 4: P2: Arduino Basic Shield: Semáforo

•  ARDUINO BASIC SHIELD

•  SALIDAS DIGITALES

•  ESQUEMA LED RGB

•  COLORES RGB

•  ESTRUCTURA FOR

•  PROGRAMA MODIFICAR

 

INFORMACIÓN

Page 5: P2: Arduino Basic Shield: Semáforo

 

ARDUINO BASIC SHIELD

LED  RGB  D5:  LED  Azul  D6:  LED  Rojo  D9:  LED  Verde    D10:  Zumbador  

Page 6: P2: Arduino Basic Shield: Semáforo

 

SALIDAS DIGITALES Hay que declararlas en el set up

Podemos escribir 5v ó 0v en el pin digital de salida

Page 7: P2: Arduino Basic Shield: Semáforo

ESQUEMA LED RGB

Page 8: P2: Arduino Basic Shield: Semáforo

Formación de los colores luz RGB

COLORES RGB

Page 9: P2: Arduino Basic Shield: Semáforo

PROGRAMA COMPLETAR

Page 10: P2: Arduino Basic Shield: Semáforo

 

ESTRUCTURA DE CONTROL FOR

Se usa para repetir las sentencias entre los corchetes for (int i=0; i<10; i++){// sentencias que queremos repetir

}

Page 11: P2: Arduino Basic Shield: Semáforo

ESQUEMA ZUMBADOR

Page 12: P2: Arduino Basic Shield: Semáforo

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

Page 13: P2: Arduino Basic Shield: Semáforo

•  ¿Qué hemos conseguido hacer?

 

reflexionamos

Page 14: P2: Arduino Basic Shield: Semáforo

     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