Top Banner
PRÁCTICAS DE PROGRAMACIÓN CON ARDUINO P7: CONTROL LED DESDE PUERTO SERIE José Pujol Pérez IES Vicente Aleixandre
14

P7: Arduino Basic Shield: Control LED desde PC

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: P7: Arduino Basic Shield: Control LED desde PC

PRÁCTICAS DE PROGRAMACIÓN CON ARDUINO

P7: CONTROL LED DESDE PUERTO SERIE

José  Pujol  Pérez  IES  Vicente  Aleixandre  

Page 2: P7: Arduino Basic Shield: Control LED desde PC

OBJETIVOS •  Realizar un control remoto

•  Practicar la comunicación serie bidireccional

•  Comprender como funciona la comunicación entre dispositivos

 

Page 3: P7: Arduino Basic Shield: Control LED desde PC

Ideas Previas:

•  ¿Qué es la comunicación serie?

•  ¿Qué dispositivos de un computador se comunican

mediante puerto serie?

•  ¿Podemos controlar Arduino desde otros

dispositivos?¿Cómo? ¿Desde qué dispositivos?

 

INTRODUCCIÓN

Page 4: P7: Arduino Basic Shield: Control LED desde PC

1º Controlar el encendido de un LED desde el teclado

del PC vía puerto serie

2º Controlar la intensidad luminosa del LED 125>

3º Controlar la intensidad luminosa del LED RGB

escribiendo:

•  r100>

•  g50>

•  b30>

 

HACER

Page 5: P7: Arduino Basic Shield: Control LED desde PC

•  COMUNICACIÓN SERIE

•  CÓDIGO ASCII

•  FUNCIÓN SERIAL

•  COMUNICACIÓN PC à ARDUINO

•  CONTROL LED DESDE PC

•  RECEPCIÓN DATOS NUMÉRICOS

 

INFORMACIÓN

Page 6: P7: Arduino Basic Shield: Control LED desde PC

 

COMUNICACIÓN SERIE

•  Comunica Arduino con PC u otros dispositivos

•  Utiliza los pines Rx 0 y Tx 1 conectados al

controlador FTDI

•  Permite recibir y enviar datos

•  Usa un buffer de 64 bytes

•  Usa el código ASCII

Page 7: P7: Arduino Basic Shield: Control LED desde PC

 

COMUNICACIÓN SERIE

Utilidades:

•  Monitorizar valores de variables

•  Depurar programas

•  Mandar comandos a Arduino desde PC

•  Conexión con módulo Bluetooth

Page 8: P7: Arduino Basic Shield: Control LED desde PC

 

CÓDIGO ASCII

Page 9: P7: Arduino Basic Shield: Control LED desde PC

FUNCIÓN SERIAL

- Serial.avalaible ();Devuelve el número de bytes almacenados en el buffer

de entrada. 0 si no hay datos

- Serial.read ();Lee el primer byte disponible en el buffer de entrada

Devuelve -1 si no hay datos

Lee el byte en formato decimal del código ASCII

Es decir si enviamos H, recibe el nº 72

Page 10: P7: Arduino Basic Shield: Control LED desde PC

 

COMUNICACIÓN PC àARDUINO

Recibe un dato por el puerto serie y lo imprime por él

Page 11: P7: Arduino Basic Shield: Control LED desde PC

CONTROL LED VIA PUERTO SERIE

Page 12: P7: Arduino Basic Shield: Control LED desde PC

RECEPCIÓN DATOS NUMÉRICOS

Page 13: P7: Arduino Basic Shield: Control LED desde PC

•  ¿Qué hemos conseguido hacer?

 

reflexionamos

Page 14: P7: Arduino Basic Shield: Control LED desde PC

     Esta  guía  se  distribuye  bajo  licencia  Reconocimiento-­‐  ComparBrIgual  CreaBve  commons  4.0    

   

(cc)  2015  José  Pujol  Pérez  Some  rights  reserved.  This  work  licensed  under  CreaBve  Commons  APribuBon-­‐ShareAlike  License.  To  view  a  copy  of  full  license,  see                  

hPp://creaBvecommons.org/licenses/by-­‐sa/3.0/  or  write  to  CreaBve  Commons,  559  Nathan  AbboP  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