<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5192187322732553132</id><updated>2024-09-13T06:06:28.423-07:00</updated><category term="arduino"/><category term="dirgan"/><category term="communication"/><category term="Introduction"/><category term="microcontroller"/><category term="pic"/><category term="design"/><category term="interactivity"/><category term="pachube"/><category term="robotic"/><category term="teensy"/><category term="pinguino"/><category term="pwm"/><category term="serial"/><category term="Introduction microcontroller pic arduino dirgan design interactivity iphone accelerometer robotic teensy"/><category term="digital output"/><category term="interaction"/><category term="internet of things"/><category term="mailbox-alert"/><category term="python"/><category term="thunderbird"/><category term="analog input"/><category term="button"/><category term="centerim"/><category term="chat"/><category term="devices"/><category term="email"/><category term="estable"/><category term="feed"/><category term="interation"/><category term="internet"/><category term="komposer"/><category term="ksh"/><category term="led"/><category term="leds"/><category term="library"/><category term="lm35"/><category term="messenger"/><category term="microncontroller"/><category term="monitoring"/><category term="output}"/><category term="processing"/><category term="programming"/><category term="regulador"/><category term="send data"/><category term="sensors"/><category term="serial communication"/><category term="serial port"/><category term="ssmtp"/><category term="twitter"/><category term="voltaje"/><category term="world wide web"/><title type='text'>MICROCONTROLADORES</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://adirgan.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://adirgan.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/15931139500048857110</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>30</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5192187322732553132.post-8022684399969306984</id><published>2015-05-16T09:02:00.003-07:00</published><updated>2015-05-16T09:04:15.577-07:00</updated><title type='text'>La internet Industrial</title><content type='html'>&lt;div style=&quot;background: rgb(255, 255, 255); border: 0px; color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 16px; line-height: 24px; margin-bottom: 24px; padding: 0px; text-align: justify; vertical-align: baseline;&quot;&gt;
&lt;a href=&quot;http://creartesoluciones.com/sistemas/files/2014/01/RevolucionIndustrial.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://creartesoluciones.com/sistemas/files/2014/01/RevolucionIndustrial.jpg&quot; height=&quot;153&quot; style=&quot;background-color: transparent;&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;span style=&quot;background: transparent; border: 0px; font-size: x-small; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;El futuro ya está sucediendo en estos momentos! En los últimos dos siglos han ocurrido dos grandes revoluciones;&lt;a href=&quot;http://es.wikipedia.org/wiki/Revoluci%C3%B3n_Industrial&quot; style=&quot;background: transparent; border: 0px; color: #743399; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;nbsp;la revolución industrial&lt;/a&gt;, en la cual nos acostumbramos a industrias mecanizadas, trenes eléctricos y viajes aéreos, lo cual cambió radicalmente nuestras vidas.&amp;nbsp;Luego de esto empezó a gestarse la revolución de Internet, la cual nos dio poder de cómputo, redes de datos y acceso sin precedentes a la información y a las comunicaciones, y de nuevo esto cambió absolutamente nuestra forma de vida. Ahora estamos experimentando otro cambio radical… uno denominado la&amp;nbsp;&lt;a href=&quot;http://en.wikipedia.org/wiki/Industrial_Internet&quot; style=&quot;background: transparent; border: 0px; color: #743399; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Internet Industrial&lt;/a&gt;, la cual amalgama dispositivos inteligentes, analítica avanzada y la creatividad de la gente que trabaja.&lt;a href=&quot;http://creartesoluciones.com/sistemas/files/2014/01/InternetIndustrial.jpg&quot; style=&quot;background: transparent; border: 0px; color: #743399; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;img alt=&quot;InternetIndustrial&quot; class=&quot;size-thumbnail wp-image-74 alignright&quot; src=&quot;http://creartesoluciones.com/sistemas/files/2014/01/InternetIndustrial-150x150.jpg&quot; height=&quot;150&quot; style=&quot;background: transparent; border: none; display: inline; float: right; margin: 4px 0px 12px 24px; padding: 0px; vertical-align: baseline;&quot; width=&quot;150&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background: transparent; border: 0px; font-size: x-small; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;La tecnología está transformando el sector industrial y esto juega un papel preponderante en la economía y en nuestra vidas: energía, transporte, salud, seguridad… para la economía esto es muy inusual, pero sin duda es muy excitante porque esto es una revolución tan poderosa como en otrora lo fuera su homologa industrial. Muchas máquinas actualmente están siendo equipadas con un número cada vez mayor de sensores electrónicos que les permiten ver, escuchar y sentir mucho más que en el pasado, generando indiscutiblemente una enorme cantidad de información y datos. Adicionalmente han surgido una nueva casta de aplicaciones emergentes (&lt;a href=&quot;http://es.wikipedia.org/wiki/Big_data&quot; style=&quot;background: transparent; border: 0px; color: #743399; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Big Data&lt;/a&gt;) basadas en software de análisis de datos, que reciben y procesan esta información produciendo material digerible y pre-analizado que nos habilita ahora a operar estas máquinas de manera totalmente diferente, y de hecho, con mucha más eficiencia.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background: rgb(255, 255, 255); border: 0px; color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 16px; line-height: 24px; margin-bottom: 24px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;a href=&quot;http://creartesoluciones.com/sistemas/files/2014/01/bigdata.jpg&quot; style=&quot;background: transparent; border: 0px; color: #743399; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;img alt=&quot;bigdata&quot; class=&quot; wp-image-76 alignleft&quot; src=&quot;http://creartesoluciones.com/sistemas/files/2014/01/bigdata-300x185.jpg&quot; height=&quot;150&quot; style=&quot;background: transparent; border: none; display: inline; float: left; margin: 4px 24px 12px 0px; padding: 0px; vertical-align: baseline;&quot; width=&quot;185&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;background: rgb(255, 255, 255); border: 0px; color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 16px; line-height: 24px; margin-bottom: 24px; padding: 0px; text-align: justify; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;background: transparent; border: 0px; font-size: x-small; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Estamos entrando en la era de los grandes volúmenes de información generados por maquinaria, aparatos domésticos, vehículos y sensores conectados en la red. Claro está, que los sensores de los cuales hablamos existen desde hace mucho tiempo… pero algo ha cambiado radicalmente. El costo de los sensores ha bajado drásticamente, han habido avances significativos en la arena del la&amp;nbsp;&lt;a href=&quot;http://es.wikipedia.org/wiki/Cloud_computing&quot; style=&quot;background: transparent; border: 0px; color: #743399; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;computación en nube&lt;/a&gt;&amp;nbsp;y además se está experimentando un descenso abrupto en&amp;nbsp; los costos del almacenamiento y del cómputo, con la integración brutal de cores y memoria en espacios cada vez más diminutos.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background: rgb(255, 255, 255); border: 0px; color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 16px; line-height: 24px; margin-bottom: 24px; padding: 0px; text-align: justify; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;background: transparent; border: 0px; font-size: x-small; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Estamos sin duda moviéndonos hacia un mundo de máquinas que no solo son rápidas, sino inteligentes y conscientes de su entorno, además de predictivas, reactivas y sociales!… son sistemas de navegación, turbinas eólicas o dispositivos médicos comunicándose entre sí y con nosotros. Es un mundo donde la información, por si misma, es inteligente y viene a nosotros cuando y donde la necesitamos sin necesidad de buscarla.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background: rgb(255, 255, 255); border: 0px; color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 16px; line-height: 24px; margin-bottom: 24px; padding: 0px; text-align: justify; vertical-align: baseline;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;background: rgb(255, 255, 255); border: 0px; color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 16px; line-height: 24px; margin-bottom: 24px; padding: 0px; text-align: justify; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;background: transparent; border: 0px; font-size: x-small; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;a href=&quot;http://creartesoluciones.com/sistemas/files/2014/01/designcrearte.jpg&quot; style=&quot;background: transparent; border: 0px; color: #743399; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;img alt=&quot;designcrearte&quot; class=&quot;alignright size-medium wp-image-176&quot; src=&quot;http://creartesoluciones.com/sistemas/files/2014/01/designcrearte-300x144.jpg&quot; height=&quot;144&quot; style=&quot;background: transparent; border: none; display: inline; float: right; height: auto; margin: 4px 0px 12px 24px; max-width: 100%; padding: 0px; vertical-align: baseline;&quot; width=&quot;300&quot; /&gt;&lt;/a&gt;Estamos empezando a implementar en todo el sistema industrial sistemas virtualizados basados en&lt;/span&gt;&lt;span style=&quot;background: transparent; border: 0px; font-size: x-small; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;nbsp;tecnologías multi-core de procesamiento y comunicación avanzada en modalidad nube, además de software especializado que permite desacoplar funcionalidades del lado aplicativo y funcionalidades del lado del hardware, ayudándonos a monitorear y gestionar de forma automática y remota muchos activos industriales. Todo esto está habilitando una nueva era preventiva y proactiva que habilita la posibilidad de tomar acciones correctivas antes que hayan fallas, sin la necesidad de perder valioso tiempo dándole servicio en un esquema rígido de mantenimiento, lo cual nos empuja a una realidad potencial de cero disrupciones de servicio, es decir, cada vez será menos frecuente experimentar apagones, atrasos o re-planificación de vuelos o eventos que nos inhabiliten a continuar nuestras vidas cotidianas.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background: rgb(255, 255, 255); border: 0px; color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 16px; line-height: 24px; margin-bottom: 24px; padding: 0px; text-align: justify; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;background: transparent; border: 0px; font-size: x-small; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Por ejemplo, hoy día muchos de los retrasos y cancelaciones en vuelos a nivel mundial son debido a eventos de&amp;nbsp; mantenimiento no planificados, lo cual representa billones de dolares en costos adicionales&amp;nbsp;&lt;a href=&quot;http://creartesoluciones.com/sistemas/files/2014/01/delayaeropuerto.jpg&quot; style=&quot;background: transparent; border: 0px; color: #743399; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;img alt=&quot;delayaeropuerto&quot; class=&quot;alignleft  wp-image-81&quot; src=&quot;http://creartesoluciones.com/sistemas/files/2014/01/delayaeropuerto-300x197.jpg&quot; height=&quot;150&quot; style=&quot;background: transparent; border: none; display: inline; float: left; margin: 4px 24px 12px 0px; padding: 0px; vertical-align: baseline;&quot; width=&quot;228&quot; /&gt;&lt;/a&gt;para las aerolíneas cada año!, amen del impacto en nosotros como usuarios del servicio al experimentar estrés, incomodidad, reuniones de trabajo incumplidas mientras pasamos horas interminables en un aeropuerto. Como esta revolución puede ayudarnos en este caso?. En la actualidad hay desarrollos de sistemas de mantenimiento preventivo que se se instalan en la aviación comercial y que a través de sistemas expertos son capaces de detectar problemas que un operador humano puede no detectar. El avión en pleno vuelo puede comunicarse con personal en tierra de forma que cuando haya aterrizado, los ingenieros y personal de mantenimiento sepan si hay algo a lo cual se le debe dar servicio. Sistemas como estos pueden prevenir miles de retrasos o cancelaciones cada año, ayudando a millones de pasajeros a llegar a sus destinos.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background: rgb(255, 255, 255); border: 0px; color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 16px; line-height: 24px; margin-bottom: 24px; padding: 0px; text-align: justify; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;background: transparent; border: 0px; font-size: x-small; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;a href=&quot;http://creartesoluciones.com/sistemas/files/2014/01/healthcare.jpg&quot; style=&quot;background: transparent; border: 0px; color: #743399; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;img alt=&quot;healthcare&quot; class=&quot;size-thumbnail wp-image-82 alignright&quot; src=&quot;http://creartesoluciones.com/sistemas/files/2014/01/healthcare-150x150.jpg&quot; height=&quot;150&quot; style=&quot;background: transparent; border: none; display: inline; float: right; margin: 4px 0px 12px 24px; padding: 0px; vertical-align: baseline;&quot; width=&quot;150&quot; /&gt;&lt;/a&gt;En el área de la salud, una enfermera puede perder hasta 20 minutos de un turno completo ubicando material y equipamiento médico, lo cual puede parecer insignificante, pero es menos tiempo destinado a la atención de un paciente. Ya hay hospitales en el mundo que implementan tecnologías que permiten conectar pacientes, doctores y equipamiento para optimizar la utilización del tiempo lo que per&lt;/span&gt;&lt;span style=&quot;background: transparent; border: 0px; font-size: x-small; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;mite atender más pacientes por unidad de tiempo, todo interconectado haciendo uso de la internet industrial. En otras instancias se están implementando esquemas de nube para almacenar información de imágenes de CT y MRIs, desarrollando mejores técnicas de análisis mientras se bajan los costos. Imaginen a un paciente que ha experimentado un gran trauma y que esté siendo atendido por diferentes especialistas, y todos ellos sean capaces de acceder de forma simultánea las imágenes escaneadas en los diferentes dispositivos.Esto repercute positivamente en un mejor diagnóstico y en un mejor tiempo de ejecución de procedimientos que permitan salvarle la vida a este paciente. Todo esto puede traducirse en mejores resultados médicos mientras se logran substanciales beneficios económicos, ya que la optimización en estas ineficiencias puede repercutir en ahorros substanciales en la industria de la salud, y esto solo es un ejemplo de como se puede intervenir un modelo tradicional para hacerlo más accesible de manera sostenida en el tiempo.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background: rgb(255, 255, 255); border: 0px; color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 16px; line-height: 24px; margin-bottom: 24px; padding: 0px; text-align: justify; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;background: transparent; border: 0px; font-size: x-small; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Avances similares están siendo experimentados en el sector de la energía, incluyendo el sector de las energías renovables. Por ejemplo, ya existen granjas eólicas equipadas con dispositivos de monitoreo interconectados entre sí, generando data muy útil para el ajuste automático de la inclinación de las palas de las hélices de las turbinas, que de manera coordinada y actuando dependiendo de las condiciones climáticas y del viento, permiten generar energía eléctrica por debajo de 5 centavos de dolar por KW/h, cuando hace 10 años costaba al menos 6 veces más. Así como estos ejemplos, existen muchos otros y la lista sigue creciendo de forma acelerada, ya que la data industrial ahora crece de forma exponencial y se estima que para el 2020 esta será al menos la mitad de toda la data digital almacenada.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background: rgb(255, 255, 255); border: 0px; color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 16px; line-height: 24px; margin-bottom: 24px; padding: 0px; text-align: justify; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;background: transparent; border: 0px; font-size: x-small; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;a href=&quot;http://creartesoluciones.com/sistemas/files/2014/01/seguridadinformatica.jpg&quot; style=&quot;background: transparent; border: 0px; color: #743399; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;img alt=&quot;seguridadinformatica&quot; class=&quot;size-thumbnail wp-image-84 alignleft&quot; src=&quot;http://creartesoluciones.com/sistemas/files/2014/01/seguridadinformatica-150x150.jpg&quot; height=&quot;150&quot; style=&quot;background: transparent; border: none; display: inline; float: left; margin: 4px 24px 12px 0px; padding: 0px; vertical-align: baseline;&quot; width=&quot;150&quot; /&gt;&lt;/a&gt;Como vemos, todo depende directa o indirectamente del almacenamiento digital, ya que la información debe mantenerse en algún lugar que debe tener algunas características fundamentales en principio: debe ser de bajo coste, debe ser seguro, debe ser rápido y debe poder accederse desde cualquier lugar. En los últimos años todas estas características han estado siendo cumplidas y el proceso de evolución es creciente por el esfuerzo de muchas compañías que se dedican a la investigación y producción de dispositivos de almacenamiento que permiten almacenar información producida por esta nueva revolución.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background: rgb(255, 255, 255); border: 0px; color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 16px; line-height: 24px; margin-bottom: 24px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;img alt=&quot;accesseverywhere&quot; class=&quot;size-medium wp-image-83 alignright&quot; src=&quot;http://creartesoluciones.com/sistemas/files/2014/01/accesseverywhere-300x89.jpg&quot; height=&quot;89&quot; style=&quot;background: transparent; border: 0px; display: inline; float: right; height: auto; margin: 4px 0px 12px 24px; max-width: 100%; padding: 0px; vertical-align: baseline;&quot; width=&quot;300&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;background: rgb(255, 255, 255); border: 0px; color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 16px; line-height: 24px; margin-bottom: 24px; padding: 0px; text-align: justify; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;background: transparent; border: 0px; font-size: x-small; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Viremos el rumbo y cambiemos un poco la perspectiva… veamos ahora como todo esto impacta nuestros trabajos cotidianos, ya que toda esta revolución nos está brindando nuevas herramientas y aplicaciones que nos permiten colaborar entre nosotros de forma más rápida e interesante, no solo permitiendo hacer nuestro trabajo de forma más eficiente sino más reconfortante. Imaginen por un momento a un ingeniero de la granja eólica con una tablet en sus manos informándole que una turbina requiere mantenimiento, contando con el stock de repuestos en sitio,&amp;nbsp; ya que este mantenimiento fue planificado con un diagnosticado temprano. Adicionalmente este mismo dispositivo permite al ingeniero comunicarse con sistemas remotos, para enviar información de diagnóstico que luego se traducirá en instrucciones detalladas de procedimientos complejos para llevar el equipamiento a su estado óptimo de nuevo, además del hecho que los procedimientos aplicados en sitio serán documentados y guardados en bases de datos que podrán ser consultadas en el futuro.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background: rgb(255, 255, 255); border: 0px; color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 16px; line-height: 24px; margin-bottom: 24px; padding: 0px; text-align: justify; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;background: transparent; border: 0px; font-size: x-small; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;a href=&quot;http://creartesoluciones.com/sistemas/files/2014/01/fast.jpg&quot; style=&quot;background: transparent; border: 0px; color: #743399; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;img alt=&quot;fast&quot; class=&quot;size-thumbnail wp-image-86 alignleft&quot; src=&quot;http://creartesoluciones.com/sistemas/files/2014/01/fast-150x150.jpg&quot; height=&quot;150&quot; style=&quot;background: transparent; border: none; display: inline; float: left; margin: 4px 24px 12px 0px; padding: 0px; vertical-align: baseline;&quot; width=&quot;150&quot; /&gt;&lt;/a&gt;Pensemos por un momento en esto, ya que estamos tocando un punto muy importante y que muchos temen. Esta revolución está cambiando la forma en que trabajamos y muchos empiezan a preocuparse de como esto puede impactar los empleos a nivel mundial. Pero la realidad es que en esta generación ya desde niños somos capaces de manejar una tablet o un computador, además de que más y más aplicaciones intuitivas e inteligentes están siendo diseñadas para hacer la vida en el trabajo más sencilla para todos los niveles de especialización, llevando al trabajador del futuro&amp;nbsp; a ser más como un Iron Man que el Charly Chaplin de tiempos modernos!. Muchos más empleos especializados serán creados en donde ingenieros electrónico-mecánicos entenderán tanto a las máquinas como a sus datos. Los gerentes deberán entender el negocio y analizar la data del mercado para así poder eventualmente reorganizar el negocio para tomar ventajas de la tecnología.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background: rgb(255, 255, 255); border: 0px; color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 16px; line-height: 24px; margin-bottom: 24px; padding: 0px; text-align: justify; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;background: transparent; border: 0px; font-size: x-small; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Sin embargo retrocedamos un segundo y veamos esto en perspectiva. Hay gente hoy que argumenta que la innovación está en los juegos y aplicaciones sociales, menospreciando la innovación que supone la industrialización de la internet y sus datos, de hecho indicando que las mejores innovaciones son del pasado. Pero no nos equivoquemos, estamos viviendo el inicio de una nueva revolución, una nueva ola tecnológica, que tendrá barreras y obstáculos que tendremos que vencer, pero que como en otras épocas cambiaron nuestras vidas por completo. No va a ser fácil, pero de seguro valdrá la pena… al ver cada vez de forma más común la interacción entre hombres y máquinas inteligentes, y la forma en que esto impacta y cambia de manera positiva el mundo, nos hacen pensar que el futuro está cerca y quizás logremos verlo en todo su esplendor!.&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://adirgan.blogspot.com/feeds/8022684399969306984/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://adirgan.blogspot.com/2015/05/el-futuro-ya-esta-sucediendo-en-estos.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/8022684399969306984'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/8022684399969306984'/><link rel='alternate' type='text/html' href='http://adirgan.blogspot.com/2015/05/el-futuro-ya-esta-sucediendo-en-estos.html' title='La internet Industrial'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/15931139500048857110</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192187322732553132.post-4845775563184906756</id><published>2014-11-27T14:12:00.002-08:00</published><updated>2014-11-27T14:12:22.572-08:00</updated><title type='text'>Building a PRINTRBOT Simple Kit 1405 in a weekend</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
The past weekend was a very challenging one. I received my PRINTRBOT Simple kit 1405.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
The following pictures depicts a excerpt of the building process that took over 12 hours of work, and at the end of this entry you will find a video of the complete time lapsed process, including some testing printings.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmdYm8bqGeViy6DDYjJA3bt60Z96AiVd40aV_SSXtW8n68odrDAdLZ9et47klqElyKzJ1FFtpvZrNJyIr0hNmPEt6IT_Em8EJc9qXio9yprzhnKYCGLhL3cG9OPNYHnUXXL_lWaDSflic/s1600/2014-11-03+11.39.12.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmdYm8bqGeViy6DDYjJA3bt60Z96AiVd40aV_SSXtW8n68odrDAdLZ9et47klqElyKzJ1FFtpvZrNJyIr0hNmPEt6IT_Em8EJc9qXio9yprzhnKYCGLhL3cG9OPNYHnUXXL_lWaDSflic/s1600/2014-11-03+11.39.12.jpg&quot; height=&quot;240&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgm5yhhnv6qYi6GkFrrYjWRp_URfod6E_NNYtcKl_iAi8q-BAC52Rr1zjh4bHq86aixhTNGEBwjNSkTnRMtenU_J-r57PVZ_qNjYbAcrHMh6me5oj4M1excXo01BAM_Hz33HbOrs6DzQ0s/s1600/2014-11-03+12.12.35.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgm5yhhnv6qYi6GkFrrYjWRp_URfod6E_NNYtcKl_iAi8q-BAC52Rr1zjh4bHq86aixhTNGEBwjNSkTnRMtenU_J-r57PVZ_qNjYbAcrHMh6me5oj4M1excXo01BAM_Hz33HbOrs6DzQ0s/s1600/2014-11-03+12.12.35.jpg&quot; height=&quot;240&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTvj3bOw_UEipXwoojiC-6wAqmzldLqzIVXoJZ9BPJ-zwIeVdaEM9Wwpa29vKtprsyP_kmOjQfyLVDiEatYrB-BEM0tnVSIPBQ_qjkCQLQdzJ7_tGyqfPbDmn7T44plTF0KNuQuhx9ptI/s1600/2014-11-03+12.58.28.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTvj3bOw_UEipXwoojiC-6wAqmzldLqzIVXoJZ9BPJ-zwIeVdaEM9Wwpa29vKtprsyP_kmOjQfyLVDiEatYrB-BEM0tnVSIPBQ_qjkCQLQdzJ7_tGyqfPbDmn7T44plTF0KNuQuhx9ptI/s1600/2014-11-03+12.58.28.jpg&quot; height=&quot;240&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicAboUAonJzcBq8ewfkxLMymcKB570ivJdOy4Pfce15eduZ1PNegTeD6CnKe0jERtWXifJ50VMjTPBcagJnDztJdGNaBzOD_rSxPu_PFscT_RMeRYIVgSOdgdhbhZGneJZKeCEBIeNYTI/s1600/2014-11-03+13.56.22.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicAboUAonJzcBq8ewfkxLMymcKB570ivJdOy4Pfce15eduZ1PNegTeD6CnKe0jERtWXifJ50VMjTPBcagJnDztJdGNaBzOD_rSxPu_PFscT_RMeRYIVgSOdgdhbhZGneJZKeCEBIeNYTI/s1600/2014-11-03+13.56.22.jpg&quot; height=&quot;240&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7Rt2REAp_x5Y7iL6pwBTezDPu0pr7ulIBQAcDTqUHZvkzw738fmfxhoTgwH9cdrZq5lHDAFziAKY1yPwJ2bloG5hyphenhyphenGynydZ74EZQB5cOl0Q-U_ePAhBJMmhuL5WD4DWHiZpt04Jf8aTM/s1600/2014-11-03+13.39.11.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7Rt2REAp_x5Y7iL6pwBTezDPu0pr7ulIBQAcDTqUHZvkzw738fmfxhoTgwH9cdrZq5lHDAFziAKY1yPwJ2bloG5hyphenhyphenGynydZ74EZQB5cOl0Q-U_ePAhBJMmhuL5WD4DWHiZpt04Jf8aTM/s1600/2014-11-03+13.39.11.jpg&quot; height=&quot;240&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&amp;nbsp;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6npJxUd_SZVApz_Wnj6haPiqjhgpDOgl8iAc3cOHQShUyOWFKrx23Y_Djr_G_3OlEd6Dfl5ePrD79cWzWAm7D808W1hh8v7i7UrY4OwMX5bjlLS44IwA9OWDDPmkQh6ANXQWYhsl06os/s1600/2014-11-03+16.08.16.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6npJxUd_SZVApz_Wnj6haPiqjhgpDOgl8iAc3cOHQShUyOWFKrx23Y_Djr_G_3OlEd6Dfl5ePrD79cWzWAm7D808W1hh8v7i7UrY4OwMX5bjlLS44IwA9OWDDPmkQh6ANXQWYhsl06os/s1600/2014-11-03+16.08.16.jpg&quot; height=&quot;240&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&amp;nbsp;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRRx_eh55qcKZMxLcTQ3CHCcdsTw6gwIta2_IK1Yq-tvyFf4IBKfLxta3EZM63rrBGM-mkCTAr3p3zxYTVloAlVmOqZw5OdvZic1cVwOZ8af4SYixCj81-07Pwke_Yp9bT4dJTr1cCGzQ/s1600/2014-11-03+18.09.51.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRRx_eh55qcKZMxLcTQ3CHCcdsTw6gwIta2_IK1Yq-tvyFf4IBKfLxta3EZM63rrBGM-mkCTAr3p3zxYTVloAlVmOqZw5OdvZic1cVwOZ8af4SYixCj81-07Pwke_Yp9bT4dJTr1cCGzQ/s1600/2014-11-03+18.09.51.jpg&quot; height=&quot;240&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&amp;nbsp;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmmTVbtThADCYxKdz8mRZ1XBDSyl0pUzcYcYJ5xpaPtlM4KXqVIm6SSSozkRdcSz9NAuScaFkUcOzowXpjPa1COuigOCC4AjmZ7ZsicPDQK9MwsLJmzkKzd3F0LOvkQOkrfY2d2FOJJAE/s1600/2014-11-08+19.16.40.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmmTVbtThADCYxKdz8mRZ1XBDSyl0pUzcYcYJ5xpaPtlM4KXqVIm6SSSozkRdcSz9NAuScaFkUcOzowXpjPa1COuigOCC4AjmZ7ZsicPDQK9MwsLJmzkKzd3F0LOvkQOkrfY2d2FOJJAE/s1600/2014-11-08+19.16.40.jpg&quot; height=&quot;240&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&amp;nbsp;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjy1at65jnobY7qwq0WrKsrI1OECTMfbg9xXphCLafNBRPDpHP6teLebJNEuIUY4SJf09NmPM6wr8JPaxL4FWsPaOD_BHZiOJ19odCSlTa9ifo1gdSkTr6baogQUfTEgNchW7oA4Zk1x6I/s1600/2014-11-08+21.08.26.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjy1at65jnobY7qwq0WrKsrI1OECTMfbg9xXphCLafNBRPDpHP6teLebJNEuIUY4SJf09NmPM6wr8JPaxL4FWsPaOD_BHZiOJ19odCSlTa9ifo1gdSkTr6baogQUfTEgNchW7oA4Zk1x6I/s1600/2014-11-08+21.08.26.jpg&quot; height=&quot;240&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&amp;nbsp;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDv8Vmegndh2bqQFtnmbjWK9f7SG09Z3XvL8Nydh9gyTBRqS_ofaDOta5qk86YvcH6EU9eJO0aShOaz7Z36gINEZGgrqjyowtpHwrtCDLRiaFF9swqqVl7ZGrFMRM6Pkvol_Wx5VujPK8/s1600/2014-11-08+21.08.47.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDv8Vmegndh2bqQFtnmbjWK9f7SG09Z3XvL8Nydh9gyTBRqS_ofaDOta5qk86YvcH6EU9eJO0aShOaz7Z36gINEZGgrqjyowtpHwrtCDLRiaFF9swqqVl7ZGrFMRM6Pkvol_Wx5VujPK8/s1600/2014-11-08+21.08.47.jpg&quot; height=&quot;240&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Here is the video... enjoy!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;object width=&quot;320&quot; height=&quot;266&quot; class=&quot;BLOGGER-youtube-video&quot; classid=&quot;clsid:D27CDB6E-AE6D-11cf-96B8-444553540000&quot; codebase=&quot;http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0&quot; data-thumbnail-src=&quot;https://ytimg.googleusercontent.com/vi/BKq8qxCAM_w/0.jpg&quot;&gt;&lt;param name=&quot;movie&quot; value=&quot;https://youtube.googleapis.com/v/BKq8qxCAM_w&amp;source=uds&quot; /&gt;&lt;param name=&quot;bgcolor&quot; value=&quot;#FFFFFF&quot; /&gt;&lt;param name=&quot;allowFullScreen&quot; value=&quot;true&quot; /&gt;&lt;embed width=&quot;320&quot; height=&quot;266&quot;  src=&quot;https://youtube.googleapis.com/v/BKq8qxCAM_w&amp;source=uds&quot; type=&quot;application/x-shockwave-flash&quot; allowfullscreen=&quot;true&quot;&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://adirgan.blogspot.com/feeds/4845775563184906756/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://adirgan.blogspot.com/2014/11/building-printrbot-simple-kit-1405-in.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/4845775563184906756'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/4845775563184906756'/><link rel='alternate' type='text/html' href='http://adirgan.blogspot.com/2014/11/building-printrbot-simple-kit-1405-in.html' title='Building a PRINTRBOT Simple Kit 1405 in a weekend'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/15931139500048857110</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmdYm8bqGeViy6DDYjJA3bt60Z96AiVd40aV_SSXtW8n68odrDAdLZ9et47klqElyKzJ1FFtpvZrNJyIr0hNmPEt6IT_Em8EJc9qXio9yprzhnKYCGLhL3cG9OPNYHnUXXL_lWaDSflic/s72-c/2014-11-03+11.39.12.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192187322732553132.post-1975122601334938240</id><published>2012-03-28T17:00:00.001-07:00</published><updated>2012-03-30T05:22:32.519-07:00</updated><title type='text'>Knob Class for Processing 2.0</title><content type='html'>I just finished a knob class (library) for processing. The idea is simple... The need of using a knob on my sketches using a simple class and interact with my microcontrollers. The goal is to have a class that can be used in a very simple way.&lt;br /&gt;
&lt;br /&gt;
The video shows how to use a knob class and a designer tool for getting the final geometry of a knob.&lt;br /&gt;
&lt;br /&gt;
The knob class is useful to create&amp;nbsp;sophisticated GUIs using Processing, a graphical java based programming environment.&lt;br /&gt;
&lt;br /&gt;
&lt;iframe class=&quot;youtube-player&quot; frameborder=&quot;0&quot; height=&quot;240&quot; src=&quot;http://www.youtube.com/embed/v3pIN3FNqHk&quot; type=&quot;text/html&quot; width=&quot;320&quot;&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;br /&gt;
Using in conjunction with the button class (&lt;a href=&quot;http://adirgan.blogspot.com/2012/03/video-button-class-for-processing-helps.html&quot; target=&quot;_blank&quot;&gt;previous article&lt;/a&gt;) we can create GUIs to interact with, showing values from variables, that we can read from microcontrollers like arduino. We&#39;ll show in the next article how to do it.&lt;br /&gt;
&lt;br /&gt;
Also we can use a knob for change values to modify other widgets or for dim a led or change the brightness of a LCD connected to a arduino... uses are&amp;nbsp;circumscribed to the imagination and needs.&lt;br /&gt;
&lt;br /&gt;
Meanwhile, it is worth to&amp;nbsp;understand&amp;nbsp;the basics of the library (class).&lt;br /&gt;
&lt;br /&gt;
The following example uses the knob class to change the background color of the window created in processing, using 3 knobs each one handling a component of a RGB tuple.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;(1) ADknob rcolor, gcolor, bcolor;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;int r,g,b;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: yellow;&quot;&gt;(2) void activateMouseWheel()&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;&amp;nbsp;addMouseWheelListener(new java.awt.event.MouseWheelListener()&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp;public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;mouseWheel(evt.getWheelRotation());&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;&amp;nbsp;});&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: yellow;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;(3) void setup()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp;size(500,200);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp;smooth();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp;rcolor = new ADknob(&quot;R&quot;,100,100,45,255,0.0,1.0,4.0,20.0,34.0,19.0,34.0,15,7,53.0,20,19,10,-6,14,5,9,14,7,23,false,11,0);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp;rcolor.setKnobPosition(234);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp;rcolor.setColors(#D30606,0,-1,0,0,0,0,-11574371,-327681);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp;gcolor = new ADknob(&quot;G&quot;,250,100,45,255,0.0,1.0,4.0,20.0,34.0,19.0,34.0,15,7,53.0,20,19,10,-6,14,5,9,14,7,23,false,11,0);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp;gcolor.setKnobPosition(202);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp;gcolor.setColors(#0FA705,0,-1,0,0,0,0,-11574371,-327681);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp;bcolor = new ADknob(&quot;B&quot;,400,100,45,255,0.0,1.0,4.0,20.0,34.0,19.0,34.0,15,7,53.0,20,19,10,-6,14,5,9,14,7,23,false,11,0);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp;bcolor.setKnobPosition(111);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp;bcolor.setColors(#050EA7,0,-1,0,0,0,0,-11574371,-327681);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;activateMouseWheel();&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;(4) void draw()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;&amp;nbsp; background(color(r,g,b));&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;&amp;nbsp; r=(int )rcolor.update();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;&amp;nbsp; g=(int )gcolor.update();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;&amp;nbsp; b=(int )bcolor.update();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;(5) void mouseDragged()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;&amp;nbsp; rcolor.change();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;&amp;nbsp; gcolor.change();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;&amp;nbsp; bcolor.change();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;(6) void mouseWheel(int delta)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;{ &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;&amp;nbsp; rcolor.changeKnobPositionWithWheel(delta);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;&amp;nbsp; gcolor.changeKnobPositionWithWheel(delta);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;&amp;nbsp; bcolor.changeKnobPositionWithWheel(delta);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: yellow; font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: orange;&quot;&gt;(1) Object Creation&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&amp;nbsp; 1.1 We start creating one object for red, green and blue component of the RGB tuple&lt;br /&gt;
&amp;nbsp; 1.2 And three integer variables for storing the knob values.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: orange;&quot;&gt;(2) The function activateMouseWheel&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&amp;nbsp; 2.1 Enable us to activate a listener for the mouse&#39;s wheel.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: orange;&quot;&gt;(3) Inside the setup function&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&amp;nbsp; 3.1 We define the windows with size() function&lt;br /&gt;
&amp;nbsp; 3.2 We instantiate each knob with the parameters obtained from the knob tool&lt;br /&gt;
&amp;nbsp; 3.3 We also set the value of the knob. This is necessary for setting an initial (r,g,b) background&lt;br /&gt;
&amp;nbsp; 3.4 Finally we call for the activation of the mouse wheel&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: orange;&quot;&gt;(4) Inside the draw() function&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&amp;nbsp; 4.1 We change the background using the variables r,g,b&lt;br /&gt;
&amp;nbsp; 4.2 These values are&amp;nbsp;obtained&amp;nbsp;from the knob.update() function, which is in charge of return&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; the value and draw the knob itself&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: orange;&quot;&gt;(5) The mouseDragged() function&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&amp;nbsp; 5.1 Enable us to call the change() method of each knob while the mouse is dragged over the knob&lt;br /&gt;
&amp;nbsp; 5.2 This function is also responsible of redrawing the knob on the screen&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: orange;&quot;&gt;(6) the function mouseWheel()&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&amp;nbsp; 6.1 It is called by the listener of the mouse using the increment or decrement of the wheel mouse&lt;br /&gt;
&amp;nbsp; 6.2 Inside we call the&amp;nbsp;changeKnobPositionWithWheel() method for updating the knob&lt;br /&gt;
&lt;br /&gt;
The structure of the code is very simple as I will describe next:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #ffd966;&quot;&gt;(1) Create the knob Object&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #ffd966;&quot;&gt;(2) Instantiate the knob with the parameters obtained from the tool inside the setup() function&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #ffd966;&quot;&gt;(3) Get the knob value and use it inside draw() function&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #ffd966;&quot;&gt;(4) Create a mouseDragged() function to call the change of the knob if we drag the mouse over&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #ffd966;&quot;&gt;(5) Create a mouseWheel() function to call&amp;nbsp;changeKnobPositionWithWheel() when we use the wheel&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Interaction:&lt;br /&gt;
&lt;br /&gt;
The knob can be used dragging the mouse over it or using the mouse wheel or the keyboard.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: orange;&quot;&gt;(1) Mouse Wheel&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&amp;nbsp; 1.1 The wheel is used to increment or decrement in one step at a time&lt;br /&gt;
&amp;nbsp; 1.2 Shift+wheel increments or decrements the knob at totalSteps/10 ratio&lt;br /&gt;
&amp;nbsp; 1.3 Ctrl+wheel&amp;nbsp;increments or decrements the knob at totalSteps/4 ratio&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: orange;&quot;&gt;(2) Keyboard&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;
&amp;nbsp; 2.1 LEFT || DOWN decrements the knob&amp;nbsp;at totalSteps/10 ratio&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; 2.2 RIGHT || UP increments&amp;nbsp;&amp;nbsp;the knob at totalSteps/10 ratio&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
Look at the video to see more details about the class and the tool and download the source to essays different examples.&lt;br /&gt;
&lt;br /&gt;
Download: &lt;a href=&quot;http://dl.dropbox.com/u/14647667/Blogs/Processing/knobDesigner/knobCLass.pde&quot; target=&quot;_blank&quot;&gt;knob class&lt;/a&gt;&lt;br /&gt;
Download: &lt;a href=&quot;http://dl.dropbox.com/u/14647667/Blogs/Processing/knobDesigner/buttonClass.pde&quot; target=&quot;_blank&quot;&gt;button class&lt;/a&gt;&lt;br /&gt;
Download: &lt;a href=&quot;http://dl.dropbox.com/u/14647667/Blogs/Processing/colors.zip&quot; target=&quot;_blank&quot;&gt;color example&lt;/a&gt;&lt;br /&gt;
Download: &lt;a href=&quot;http://dl.dropbox.com/u/14647667/Blogs/Processing/knobDesigner.zip&quot; target=&quot;_blank&quot;&gt;Designer tool&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://adirgan.blogspot.com/feeds/1975122601334938240/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://adirgan.blogspot.com/2012/03/knob-class-for-processing-20.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/1975122601334938240'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/1975122601334938240'/><link rel='alternate' type='text/html' href='http://adirgan.blogspot.com/2012/03/knob-class-for-processing-20.html' title='Knob Class for Processing 2.0'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/15931139500048857110</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/v3pIN3FNqHk/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192187322732553132.post-4438889225280730384</id><published>2012-03-17T09:12:00.000-07:00</published><updated>2012-03-17T09:12:13.719-07:00</updated><title type='text'>VIDEO: Button Class for Processing helps Arduino&#39;s Interaction</title><content type='html'>This is a very short video which&amp;nbsp;demonstrates&amp;nbsp;how the button class helps to&amp;nbsp;interact&amp;nbsp;with a microcontroller like teensy (arduino clone).&lt;br /&gt;
&lt;br /&gt;
&lt;iframe class=&quot;youtube-player&quot; frameborder=&quot;0&quot; height=&quot;240&quot; src=&quot;http://www.youtube.com/embed/9JrPfVlAjqE&quot; type=&quot;text/html&quot; width=&quot;320&quot;&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;DISCLAIMER **&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;THIS SOFTWARE IS PROVIDED TO YOU &quot;AS IS,&quot; AND WE MAKE NO EXPRESS OR IMPLIED WARRANTIES WHATSOEVER WITH RESPECT TO ITS FUNCTIONALITY, OPERABILITY, OR USE, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR INFRINGEMENT. WE EXPRESSLY DISCLAIM ANY LIABILITY WHATSOEVER FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR SPECIAL DAMAGES, INCLUDING, WITHOUT LIMITATION, LOST REVENUES, LOST PROFITS, LOSSES RESULTING FROM BUSINESS INTERRUPTION OR LOSS OF DATA, REGARDLESS OF THE FORM OF ACTION OR LEGAL THEORY UNDER WHICH THE LIABILITY MAY BE ASSERTED, EVEN IF ADVISED OF THE POSSIBILITY OR LIKELIHOOD OF SUCH DAMAGES.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: orange;&quot;&gt;Download source: &lt;/span&gt;&lt;a href=&quot;http://dl.dropbox.com/u/14647667/Blogs/Processing/ledSwicthWithButtons.pde&quot;&gt;ledSwicthesWithButtons.pde&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;color: orange;&quot;&gt;Download source: &lt;/span&gt;&lt;a href=&quot;http://dl.dropbox.com/u/14647667/Blogs/Processing/buttonClass.pde&quot;&gt;buttonClass.pde&lt;/a&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adirgan.blogspot.com/feeds/4438889225280730384/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://adirgan.blogspot.com/2012/03/video-button-class-for-processing-helps.html#comment-form' title='1 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/4438889225280730384'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/4438889225280730384'/><link rel='alternate' type='text/html' href='http://adirgan.blogspot.com/2012/03/video-button-class-for-processing-helps.html' title='VIDEO: Button Class for Processing helps Arduino&#39;s Interaction'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/15931139500048857110</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/9JrPfVlAjqE/default.jpg" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192187322732553132.post-7878231327245196903</id><published>2012-03-16T15:46:00.002-07:00</published><updated>2012-03-16T17:02:43.243-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="button"/><category scheme="http://www.blogger.com/atom/ns#" term="interation"/><category scheme="http://www.blogger.com/atom/ns#" term="library"/><category scheme="http://www.blogger.com/atom/ns#" term="processing"/><title type='text'>Simple Button Class for Processing</title><content type='html'>&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: orange; font-size: large;&quot;&gt;Abstract&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Continuing with our goal of communicating with arduino like micros, this time I brought you with a simple button class to use with processing. I&#39;ve made a simple example of how to use it and also I have created a more elaborated example, using the buttons to turn on/off leds of my teensy.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;iframe class=&quot;youtube-player&quot; frameborder=&quot;0&quot; height=&quot;240&quot; src=&quot;http://www.youtube.com/embed/Wq8xt7w0QAk&quot; type=&quot;text/html&quot; width=&quot;320&quot;&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;color: orange; font-size: large;&quot;&gt;&lt;b&gt;Simple Button Class for Processing&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The idea is to use it, as is, with no knowlegde about how to code a button... that&#39; s why this class is like a library.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;DISCLAIMER **&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;THIS SOFTWARE IS PROVIDED TO YOU &quot;AS IS,&quot; AND WE MAKE NO EXPRESS OR IMPLIED WARRANTIES WHATSOEVER WITH RESPECT TO ITS FUNCTIONALITY, OPERABILITY, OR USE, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED&amp;nbsp;WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR INFRINGEMENT. WE EXPRESSLY&amp;nbsp;DISCLAIM ANY LIABILITY WHATSOEVER FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR SPECIAL&amp;nbsp;DAMAGES, INCLUDING, WITHOUT LIMITATION, LOST REVENUES, LOST PROFITS, LOSSES RESULTING FROM BUSINESS&amp;nbsp;INTERRUPTION OR LOSS OF DATA, REGARDLESS OF THE FORM OF ACTION OR LEGAL THEORY UNDER WHICH THE LIABILITY&amp;nbsp;MAY BE ASSERTED, EVEN IF ADVISED OF THE POSSIBILITY OR LIKELIHOOD OF SUCH DAMAGES.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
A simple example in the following lines:&lt;br /&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;ADbutton button1;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;&amp;nbsp;boolean pressed=false;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;&amp;nbsp;void setup()&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;&amp;nbsp;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;size(290,120);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;smooth();&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;&amp;nbsp; button1 = new ADbutton(80, 40, 150, 30, 7, &quot;Press Me&quot;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;&amp;nbsp;void buttonRun()&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;&amp;nbsp;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if (pressed)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;button1.label(&quot;Press Me&quot;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;else&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;button1.label(&quot;unPress Me&quot;);&lt;/span&gt;&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;pressed=!pressed;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;&amp;nbsp;void draw()&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;&amp;nbsp;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;background(#04583F);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if (button1.update())&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; buttonRun();&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime; font-size: x-small;&quot;&gt;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
A very simple approach to use button to run functions each time a button is pressed. This example instantiate button1,inside setup(),&amp;nbsp;based on ADbutton class indicating (x,y) position on the screen, (width,height) of the button, radius of the rounded corners of the button and the label.&lt;br /&gt;
&lt;br /&gt;
Then, on function draw() we run button1.update() that has to goals: the first one is to draw the button itself and the second one is to return a boolean indicating if the button was pressed.&lt;br /&gt;
&lt;br /&gt;
If the button was pressed is evaluated at the if statement. If the returned value is true it runs buttonRun() function.&lt;br /&gt;
&lt;br /&gt;
In the buttonRun() function we evaluate the boolean pressed variable to change the label of the button, so it behaves like a push button.&lt;br /&gt;
&lt;br /&gt;
The better way I found to use the class is to create a tab on processing, copy and paste the code and then create your program in the main tab using the class.&lt;br /&gt;
&lt;br /&gt;
The video shows the quick deploy of the class...&lt;br /&gt;
&lt;br /&gt;
&lt;iframe class=&quot;youtube-player&quot; frameborder=&quot;0&quot; height=&quot;240&quot; src=&quot;http://www.youtube.com/embed/Wq8xt7w0QAk&quot; type=&quot;text/html&quot; width=&quot;320&quot;&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;br /&gt;
Download: &lt;a href=&quot;http://dl.dropbox.com/u/14647667/Blogs/Processing/buttonClass.pde&quot;&gt;buttonClass.pde&lt;/a&gt;&lt;br /&gt;
Download: &lt;a href=&quot;http://dl.dropbox.com/u/14647667/Blogs/Processing/arrayOfButtons.pde&quot;&gt;arrayOfButtons.pde&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://adirgan.blogspot.com/feeds/7878231327245196903/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://adirgan.blogspot.com/2012/03/simple-button-class-for-processing.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/7878231327245196903'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/7878231327245196903'/><link rel='alternate' type='text/html' href='http://adirgan.blogspot.com/2012/03/simple-button-class-for-processing.html' title='Simple Button Class for Processing'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/15931139500048857110</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/Wq8xt7w0QAk/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192187322732553132.post-5113038649161877013</id><published>2012-03-10T11:53:00.000-08:00</published><updated>2012-03-10T12:29:40.593-08:00</updated><title type='text'>Internet of things: Sending data to Twitter using Python - part I</title><content type='html'>&lt;span style=&quot;color: orange; font-size: large;&quot;&gt;&lt;b&gt;Abstract&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Continuing&amp;nbsp;with the goal of sending data using different means to connect a microcontroller to the outside world, this time we are going to describe how to interact with twitter as a way to show messages triggered by conditions defined and showing values of any kind of sources.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
This article is divided in 2 parts. The first one is intended to show you how to send data from our computer to twitter. The second one is going to be dedicated to explains the procedure that have to be followed to send data produced by different sources to Twitter.&lt;br /&gt;
&lt;br /&gt;
See the video:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;iframe class=&quot;youtube-player&quot; frameborder=&quot;0&quot; height=&quot;240&quot; src=&quot;http://www.youtube.com/embed/rJAMHAT9FlM&quot; type=&quot;text/html&quot; width=&quot;320&quot;&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: orange; font-size: large;&quot;&gt;&lt;b&gt;Sending data to Twitter - part I&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
What we want to do is obtain data from a source (i.e. a sensor), then&amp;nbsp;analyze it to trigger messages depending on specific conditions. With this goal in mind the first step is to know how the messaging system of twitter actually works.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
In order to send messages &amp;nbsp;to twitter from command line it is not enough to use curl or whatever command line tool to send messages over internet.&amp;nbsp;Instead, Twitter clients will need to use more secure authentication based on &lt;a href=&quot;https://dev.twitter.com/docs/auth/oauth/faq&quot; target=&quot;_blank&quot;&gt;OAuth&lt;/a&gt;.&amp;nbsp;OAuth is an authentication protocol that allows users to approve application to act on their behalf without sharing their password.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
So this first part is going to help people to know what is the lifecycle to get ready for sending messages.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: orange;&quot;&gt;(1) Download&amp;nbsp;&lt;a href=&quot;http://tweepy.github.com/&quot; target=&quot;_blank&quot;&gt;Tweepy&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
To interact easily with Twitter from Python, is imperative to get in hand an API that can be used to get an&amp;nbsp;abstraction, this way is easier to program what we need. It is worth to say that&amp;nbsp;Tweepy is a very well documented Twitter library for Python.&amp;nbsp;This is the python API that we will use to authenticate against twitter and send messages.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: orange;&quot;&gt;(2) Create the application on &amp;nbsp;&lt;a href=&quot;https://dev.twitter.com/apps&quot;&gt;https://dev.twitter.com/apps&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Here you can create as much as applications as you need. This step will provide you with two&amp;nbsp;authentication&amp;nbsp;pieces required for the next step.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CONSUMER_KEY&lt;br /&gt;
CONSUMER_SECRET&lt;br /&gt;
&lt;br /&gt;
It is important to remember to configure the application to Read, Write and Access direct messages located on settings tab.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: orange;&quot;&gt;(3) Authenticate&amp;nbsp;against&amp;nbsp;the application created in the above step.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
This step engage with the authentication procedure of twitter and will provide you with another two pieces required to send the messages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ACCESS_KEY&lt;br /&gt;
ACCESS_SECRET&lt;br /&gt;
&lt;br /&gt;
The following script do this engage, just replace key and secret.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;#!/usr/bin/python&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;import tweepy&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;CONSUMER_KEY = &#39;&lt;/span&gt;&lt;span style=&quot;color: cyan;&quot;&gt;put here the consumer key&lt;/span&gt;&lt;span style=&quot;color: lime;&quot;&gt;&#39;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;CONSUMER_SECRET = &#39;&lt;/span&gt;&lt;span style=&quot;color: cyan;&quot;&gt;put here de consumer secret&lt;/span&gt;&lt;span style=&quot;color: lime;&quot;&gt;&#39;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;auth_url = auth.get_authorization_url()&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;print &#39;Use this URL to get the PIN: &#39; + auth_url&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;PIN = raw_input(&#39;PIN?: &#39;).strip()&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;auth.get_access_token(PIN)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;print &quot;ACCESS_KEY = &#39;%s&#39;&quot; % auth.access_token.key&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;print &quot;ACCESS_SECRET = &#39;%s&#39;&quot; % auth.access_token.secret&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Execute the script, copy and paste the url on your favorite browser and get the PIN. Introduce this PIN number and the script will print the access_key and access_secret required for the next step.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: orange;&quot;&gt;(4) Sending messages to Twitter&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
With the information gathered before and a script created using the Tweepy API it is very easy to send messages. The following code is depict the simple procedure of getting the message using a command line parameter and then send the message to twitter.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;#!/usr/bin/python&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;#sendMessage2Twitter.py&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;import sys&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;import tweepy&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;CONSUMER_KEY = &#39;&lt;/span&gt;&lt;span style=&quot;color: cyan;&quot;&gt;put here the consumer key&lt;/span&gt;&lt;span style=&quot;color: lime;&quot;&gt;&#39;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;CONSUMER_SECRET = &#39;&lt;/i&gt;&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: cyan;&quot;&gt;put here the consumer secret&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&#39;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;ACCESS_KEY = &#39;&lt;/i&gt;&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: cyan;&quot;&gt;put here the access key&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&#39;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;ACCESS_SECRET = &#39;&lt;/i&gt;&lt;/span&gt;&lt;i&gt;&lt;span style=&quot;color: cyan;&quot;&gt;put here the access secret&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&#39;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;api = tweepy.API(auth)&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;api.update_status(sys.argv[1])&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
So, the last line get its argument from command line and update the status of our twitter, just by doing this.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #ffe599;&quot;&gt;./sendMessage2Twitter.py &quot;This is a test of sending messages to twitter from command line using #teewpy and #python&quot;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
You can extend the script to gather any kind of information and send it to twitter. The next article will be dealing with getting info from a microcontroller and send it to twitter using this procedure.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: orange;&quot;&gt;&lt;b&gt;VIDEO&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: orange;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;iframe class=&quot;youtube-player&quot; frameborder=&quot;0&quot; height=&quot;240&quot; src=&quot;http://www.youtube.com/embed/rJAMHAT9FlM&quot; type=&quot;text/html&quot; width=&quot;320&quot;&gt;&lt;/iframe&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Enjoy!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;code&gt;
&lt;/code&gt;</content><link rel='replies' type='application/atom+xml' href='http://adirgan.blogspot.com/feeds/5113038649161877013/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://adirgan.blogspot.com/2012/03/internet-of-things-sending-data-to.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/5113038649161877013'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/5113038649161877013'/><link rel='alternate' type='text/html' href='http://adirgan.blogspot.com/2012/03/internet-of-things-sending-data-to.html' title='Internet of things: Sending data to Twitter using Python - part I'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/15931139500048857110</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/rJAMHAT9FlM/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192187322732553132.post-178501578817835902</id><published>2012-02-27T09:50:00.001-08:00</published><updated>2012-02-27T09:50:28.022-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="communication"/><category scheme="http://www.blogger.com/atom/ns#" term="lm35"/><category scheme="http://www.blogger.com/atom/ns#" term="pachube"/><category scheme="http://www.blogger.com/atom/ns#" term="serial"/><title type='text'>Sending temperature data to pachube using pic based microcontroller</title><content type='html'>&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: orange; font-size: large;&quot;&gt;Abstract&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
In my &lt;a href=&quot;http://adirgan.blogspot.com/2012/02/how-to-send-data-to-pachube.html&quot; target=&quot;_blank&quot;&gt;previous article&lt;/a&gt; I described a way to send data to a feed created on pachube to store data that came from a temperature sensor of my laptop. The article was intended to show the procedure that has to be followed to send data to pachube&#39;s feed.&lt;br /&gt;
&lt;br /&gt;
In this article I am going to show you how to obtain data from a lm35 (temperature) sensor&amp;nbsp;attached&amp;nbsp;to a arduino like board (pinguino), send them to pachube&#39;s feed and then visualize the data using Komposer.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: orange; font-size: large;&quot;&gt;&lt;b&gt;Sending temperature data to pachube using pic based microcontroller&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The first thing that we have to understand is the whole picture. The following image shows you how is &amp;nbsp;the relationship&amp;nbsp;among the different&amp;nbsp;components.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEif-Z_mJpCBn8F8pcKYmz8Ztx0R0xbkJtbWuE9yqkBMwN-kJ9eV_CIvnqAh0CF_UxahV1BUm0nTfCHUqqkiKNXaUMt2C-tPBp3bnub9jx8HGVw2R9trA1vy7oLpvKzMJQ5R2-HfnjkVkMQ/s1600/connectionScheme.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;300&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEif-Z_mJpCBn8F8pcKYmz8Ztx0R0xbkJtbWuE9yqkBMwN-kJ9eV_CIvnqAh0CF_UxahV1BUm0nTfCHUqqkiKNXaUMt2C-tPBp3bnub9jx8HGVw2R9trA1vy7oLpvKzMJQ5R2-HfnjkVkMQ/s400/connectionScheme.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
The components required are:&lt;br /&gt;
&lt;br /&gt;
1x &lt;a href=&quot;http://www.national.com/mpf/LM/LM35.html#Overview&quot;&gt;LM35&amp;nbsp;Precision Centigrade Temperature Sensor&lt;/a&gt;&lt;br /&gt;
1x &lt;a href=&quot;http://pic%202550%20based%20pinguino%20%28arduino%20like%20board%29%20or%20arduino%20board%281%29/&quot;&gt;Pic 2550 based Pinguino (arduino like board) or arduino board(1)&lt;/a&gt;&lt;br /&gt;
1x PC using linux (I use Ubuntu 11.10) with python installed&lt;br /&gt;
&lt;br /&gt;
The above image shows the LM35 sensor&amp;nbsp;attached&amp;nbsp;to the microcontroller which is responsible for reading the analog pin where the sensor is attached, calculates an average of the values red and converts them to centigrades, then send this value through the serial port to the PC.&lt;br /&gt;
&lt;br /&gt;
The PC will receive the values through the serial port where a python script is in charge for reading each value of temperature and send it to pachube&#39;s feed (previously created on pachube&#39;s web site).&lt;br /&gt;
&lt;br /&gt;
A third component is related to the way we can access the data in a form of a charts such that we can easily see temperatures trends over an hour, a day or a week. This component is a simple static web page created with komposer.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: orange; font-size: large;&quot;&gt;&lt;b&gt;Firt things first&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The first thing we have to solve is reading the sensor from the microcontroller. To do this we have to have the components and attach them using a protoboard.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifxflMelLqXleoQZwcsnxg0MvVV5d8XKyh4P5h2L6Y3ZPW5R28bY76eGqWlX7tdkHVBfGE275YZ4RhYcLQ1nR6nfX9yRcJd_1p15WQcpyQIYPsDFyXp8-1tWcAuO_AvMMvYB4FKC0AGs8/s1600/fritzing.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;362&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifxflMelLqXleoQZwcsnxg0MvVV5d8XKyh4P5h2L6Y3ZPW5R28bY76eGqWlX7tdkHVBfGE275YZ4RhYcLQ1nR6nfX9yRcJd_1p15WQcpyQIYPsDFyXp8-1tWcAuO_AvMMvYB4FKC0AGs8/s400/fritzing.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
I have used &lt;a href=&quot;http://fritzing.org/&quot; target=&quot;_blank&quot;&gt;fritzing&lt;/a&gt; to do this model where you can see the lm35 attached to the pin13 of our pinguino. The pin 13 is analog so it is suitable to read different voltages (0-5V). The LM35 is very simple to connect and read. It has only 3 pins (VCC, VOUT, GND). This&amp;nbsp;&lt;a href=&quot;http://www.ladyada.net/learn/sensors/tmp36.html&quot; target=&quot;_blank&quot;&gt;link&lt;/a&gt;&amp;nbsp;has a very good tutorial of how to read and convert the Vout value so the reading sent to the serial port is easily read in its final scale.&lt;br /&gt;
&lt;br /&gt;
For this schematic we have used a pull-up 10K&amp;nbsp;resistor due to the fact that pinguino 2550 lacks of these internally.&amp;nbsp;VCC and GND comes directly from the pinguino VCC and GND.&lt;br /&gt;
&lt;br /&gt;
With this all set on our protoboard it is time to load the code on the micro using the &lt;a href=&quot;http://wiki.pinguino.cc/index.php/Main_Page&quot; target=&quot;_blank&quot;&gt;32 bit Pinguino&#39;s IDE&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;byte pinTemp=14;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;void setup()&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;{&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp;pinMode(pinTemp,INPUT);&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;}&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;float temp(byte pin, int n, int milis)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;{&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; int i=0;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; int valorPin=0;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; //read cycle defined by n iterations waiting (millis) milliseconds&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; for (i=0; i&amp;lt;n; i++)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; {&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; valorPin= valorPin + analogRead(pin);&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; delay(milis);&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; }&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; //return the average value coverted to celcius&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; return (5.0 * (valorPin/n) * 100.0)/1024.0; &amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;}&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;void loop()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp;CDC.printf(&quot;%d\n&quot;, (int)temp(pinTemp,100,600));&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
A little&amp;nbsp;explanation of the code:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
1) On the setup() block we initialize the pin as an analog input.&lt;/div&gt;
&lt;div&gt;
2) On the loop() block we print the result to the serial port using CDC and the custom temp() function.&lt;/div&gt;
&lt;div&gt;
3) On the temp() function we calculate the average of 100 values red with analogRead(), each one executed every 600 milliseconds, then return the value converted to centigrades.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
With 100 reads each one executed every 600 millis we will obtain a temperature value every minute or so. This value is sent to the serial port (/dev/ttyACM0) and can be red with the following script using python.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;#!/usr/bin/python&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&quot;&quot;&quot;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;tempLM35.py&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&quot;&quot;&quot;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;import os.path&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;from datetime import datetime&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;import serial&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;import signal&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;import sys&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;import subprocess&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;import eeml&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;pachubeURL=&quot;/v2/feeds/47024.xml&quot;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;pachubeKEY=&quot;bfr0eqPG26CdsRgwTOrgIPZV86DRGJr1q9Ept4ZjaJ8&quot;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;#Verificacion del parametro indicando el puerto serial /dev/ttyXXX&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;if len(sys.argv) &amp;gt; 1:&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp;if os.path.exists(sys.argv[1]):&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; puerto = sys.argv[1]&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp;else:&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;El puerto especificado %s no existe!&quot; % (sys.argv[1])&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; sys.exit(1)&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;else:&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp;print &quot;uso: showSerial.py /dev/ttyXXXX&quot;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp;sys.exit()&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;#Apertura puerto serial&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;try:&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp;ser = serial.Serial(puerto, 9600)&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;except (serial.ValueError, serial.SerialException):&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp;print &quot;\n::Error::\n Puerto=%s&quot; % (puerto)&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp;sys.exit(2)&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;#Funcion para el catch del ^C&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;def signal_handler(signal, frame):&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp;print &#39; Saliendo...&#39;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp;ser.close()&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp;sys.exit(0)&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;signal.signal(signal.SIGINT, signal_handler)&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;pachube = eeml.Pachube(pachubeURL,pachubeKEY)&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;#while 1:&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;try:&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp;result=ser.readline()&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;except serial.SerialException:&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp;print &quot;\n::Error::\n Puerto=%s&quot; % (puerto)&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp;sys.exit(2)&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&lt;b&gt;result=result.replace(&quot;\n&quot;,&quot;&quot;)&lt;/b&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&lt;b&gt;pachube.update([eeml.Data(0, result, unit=eeml.Celsius())])&lt;/b&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;&lt;b&gt;pachube.put()&lt;/b&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;i&gt;print &quot;(&quot;+str(datetime.now())+&quot;) --&amp;gt; &quot;+result+&quot; Celsius&quot;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
At the end of this code we use the eeml library to update and send one value to the feed&amp;nbsp;&lt;b&gt;47024&lt;/b&gt;&amp;nbsp;referred&amp;nbsp;with &lt;b&gt;pachubeURL&lt;/b&gt; variable using our unique key for authentication (&lt;b&gt;pachubeKEY&lt;/b&gt;).&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
This script have to be executed each time we decide to obtain a value from the serial port and send it to pachube&#39;s feed. Linux give us a tool called &lt;a href=&quot;https://help.ubuntu.com/community/CronHowto&quot; target=&quot;_blank&quot;&gt;cron&lt;/a&gt;. Updating the crontab to execute the script every minute allows us to send the data at the same rate of the microcontroller.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;* * * * * /home/ydirgan/SCRIPTS/pachube/tempLM35.py /dev/ttyACM0 &amp;gt;&amp;gt;/home/ydirgan/SCRIPTS/pachube/tempLM35.out 2&amp;gt;&amp;amp;1&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The last line of the python script prints out the following formatted line (ie):&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: yellow;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: yellow;&quot;&gt;(2012-02-27 12:18:19.740213) --&amp;gt; 28 Celsius&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: yellow;&quot;&gt;(2012-02-27 12:19:10.317034) --&amp;gt; 29 Celsius&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: yellow;&quot;&gt;(2012-02-27 12:20:51.447645) --&amp;gt; 28 Celsius&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: yellow;&quot;&gt;(2012-02-27 12:21:41.929904) --&amp;gt; 28 Celsius&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
As you can notice on the cron entry above, the script is executed redirecting the referred output to tempLM35.out which will contain the historical values red from the sensor. This file can be used to create a chart on (i.e.) a libreoffice spreadsheet utility.&amp;nbsp;Instead, we use pachube to store that data and let it to create the charts.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Finally using the same technique from our &lt;a href=&quot;http://adirgan.blogspot.com/2012/02/using-komposer-to-visualize-pachube-s.html&quot; target=&quot;_blank&quot;&gt;last article&lt;/a&gt; (using komposer) we can show the charts in one page and using labels to identify the charts and to make easier the interpretation.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyVYpXEwWGfzfLI3b8WucUnOejsVzjvV8r_WQuhhoC4TpehgCjMdkdTdi2F72HsOL2S4NA17OqshD-qd5g1X6jbCVsFGaVl3gZ4fpGJ-xz3lg6mHtjCvLEgHLVFPJ2cn5pdVQyi3AlFk4/s1600/kompozer.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;180&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyVYpXEwWGfzfLI3b8WucUnOejsVzjvV8r_WQuhhoC4TpehgCjMdkdTdi2F72HsOL2S4NA17OqshD-qd5g1X6jbCVsFGaVl3gZ4fpGJ-xz3lg6mHtjCvLEgHLVFPJ2cn5pdVQyi3AlFk4/s400/kompozer.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
Using an&amp;nbsp;auto-load&amp;nbsp;plugin on the browser you can keep up to date this page to see what is going on with the&amp;nbsp;temperature&amp;nbsp;of the room.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #ffd966; font-size: large;&quot;&gt;&lt;b&gt;follow us on&amp;nbsp;&lt;a href=&quot;https://twitter.com/#ydirgan&quot; target=&quot;_blank&quot;&gt;twitter&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;https://plus.google.com/b/111940495387297822358/&quot; target=&quot;_blank&quot;&gt;G+&lt;/a&gt;&amp;nbsp;or &lt;a href=&quot;https://www.facebook.com/groups/mmiiccrrooss/&quot; target=&quot;_blank&quot;&gt;Facebook&lt;/a&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adirgan.blogspot.com/feeds/178501578817835902/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://adirgan.blogspot.com/2012/02/sending-temperature-data-to-pachube.html#comment-form' title='4 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/178501578817835902'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/178501578817835902'/><link rel='alternate' type='text/html' href='http://adirgan.blogspot.com/2012/02/sending-temperature-data-to-pachube.html' title='Sending temperature data to pachube using pic based microcontroller'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/15931139500048857110</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEif-Z_mJpCBn8F8pcKYmz8Ztx0R0xbkJtbWuE9yqkBMwN-kJ9eV_CIvnqAh0CF_UxahV1BUm0nTfCHUqqkiKNXaUMt2C-tPBp3bnub9jx8HGVw2R9trA1vy7oLpvKzMJQ5R2-HfnjkVkMQ/s72-c/connectionScheme.png" height="72" width="72"/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192187322732553132.post-544374418976952635</id><published>2012-02-16T19:24:00.000-08:00</published><updated>2012-02-18T06:56:19.043-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="internet of things"/><category scheme="http://www.blogger.com/atom/ns#" term="komposer"/><category scheme="http://www.blogger.com/atom/ns#" term="pachube"/><category scheme="http://www.blogger.com/atom/ns#" term="sensors"/><category scheme="http://www.blogger.com/atom/ns#" term="world wide web"/><title type='text'>Internet of Things: Using Komposer to visualize Pachube&#39; s charts</title><content type='html'>In my&amp;nbsp;&lt;a href=&quot;http://adirgan.blogspot.com/2012/02/how-to-send-data-to-pachube.html&quot;&gt;previous&amp;nbsp;article&lt;/a&gt; I described the way to send data to pachube and showed a little example of how to show the charts&amp;nbsp;alternatively.&lt;br /&gt;
&lt;br /&gt;
The way Pachube shows charts can be modified to our&amp;nbsp;requirements&amp;nbsp;using Komposer. The video is self explanatory... take a look!&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: orange;&quot;&gt;&lt;b&gt;VIDEO: &lt;/b&gt;&lt;/span&gt;&lt;a href=&quot;http://www.youtube.com/watch?v=slApjJ4OW9U&quot;&gt;How to create a litlle Web Page to visualize Pachube&#39;s Charts&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://adirgan.blogspot.com/feeds/544374418976952635/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://adirgan.blogspot.com/2012/02/using-komposer-to-visualize-pachube-s.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/544374418976952635'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/544374418976952635'/><link rel='alternate' type='text/html' href='http://adirgan.blogspot.com/2012/02/using-komposer-to-visualize-pachube-s.html' title='Internet of Things: Using Komposer to visualize Pachube&#39; s charts'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/15931139500048857110</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192187322732553132.post-4034546231266547676</id><published>2012-02-05T14:56:00.000-08:00</published><updated>2012-02-09T12:15:07.551-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="communication"/><category scheme="http://www.blogger.com/atom/ns#" term="feed"/><category scheme="http://www.blogger.com/atom/ns#" term="internet of things"/><category scheme="http://www.blogger.com/atom/ns#" term="monitoring"/><category scheme="http://www.blogger.com/atom/ns#" term="pachube"/><category scheme="http://www.blogger.com/atom/ns#" term="send data"/><title type='text'>Internet of things: How to send data to Pachube</title><content type='html'>&lt;div id=&quot;google_translate_element&quot;&gt;
&lt;/div&gt;
&lt;script&gt;
function googleTranslateElementInit() {
  new google.translate.TranslateElement({
    pageLanguage: &#39;en&#39;
  }, &#39;google_translate_element&#39;);
}
&lt;/script&gt;&lt;script src=&quot;//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit&quot;&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;span style=&quot;color: orange; font-size: large;&quot;&gt;&lt;b&gt;Abstract&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://adirgan.blogspot.com/2012/01/internet-of-things.html&quot;&gt;Last article&lt;/a&gt; was dedicated to describe Pachube, today I am going to show you how to send data from a PC to datastreams created on Pachube&#39;s Web Site. The information depicted here will give you a general idea of the procedures needed to send information to a datastream from a sensor inside a laptop (i.e. temperature sensor) , and in the next article we will use this background to obtain values from a temperature sensor attached to an arduino platform, to have a chart updated in real time at pachube.&lt;br /&gt;
&lt;br /&gt;
This way we can have a database of any kind of values obtained from any source of data on the internet, totally free and 24 hours uptime.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: orange;&quot;&gt;VIDEO:&lt;/span&gt;&lt;/b&gt; &lt;a href=&quot;http://youtu.be/sdkpOfRXItI&quot;&gt;How to send data to a feed on pachube&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
So, let get started.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: orange; font-size: large;&quot;&gt;&lt;b&gt;How to send data to patchube&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
A feed is a database that we can create on www.pachube.com, after create an account. This service is free and can be used anywhere.&lt;br /&gt;
&lt;br /&gt;
A quickstart of pachube can be accessed &lt;a href=&quot;https://pachube.com/docs/quickstart/twitter.html&quot;&gt;here&lt;/a&gt;, where there are instructions to automatically get statistical information of out twitter.. give it a try!&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: orange;&quot;&gt;VIDEO:&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&lt;a href=&quot;http://youtu.be/sdkpOfRXItI&quot;&gt;How to send data to a feed on pachube&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Once we have created a feed, we are ready to send information to our database.&lt;br /&gt;
&lt;br /&gt;
There are several ways to do it. I have chosen the python method due to it&#39;s versatility and because python is multi-platform.&lt;br /&gt;
&lt;br /&gt;
For our experiment I have decided to read the temperature of my laptop based on Ubuntu. This can be accomplished using the &lt;i&gt;&lt;span style=&quot;color: yellow;&quot;&gt;sensors&lt;/span&gt;&lt;/i&gt; command. Using a simple filter we can isolate the temperature value from the output of sensors:&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;acpitz-virtual-0&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;Adapter: Virtual device&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;temp1: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;+54.0°C &amp;nbsp;(crit = +100.0°C)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;temp2: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;+54.0°C &amp;nbsp;(crit = +100.0°C)&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
I have used the follwing command to isolate the temperature &amp;nbsp;value of one of the cores of my laptop Dell.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;sensors | grep temp1 | cut -d: -f2 | awk &#39;{print $1}&#39; | sed s/+//g | sed s/&quot;°C&quot;//g&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
... and the result after I execute the above command is:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;54.0&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Which is the temperature that I want to send and have a chart of it.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
After we are confident that we can obtain a consistent value every time we ask for it, it is time to create the python script to get that value and send it to our database on pachube. We can send a value every 30 seconds or every minute, or using the interval that is suitable for our application. This interval is going to be programmed using the automated command execution facility on linux called cron.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The code is very simple and is written below:&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;1 #!/usr/bin/python&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;2 import subprocess&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;3 import eeml&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;4 pachubeURL=&quot;/v2/feeds/47024.xml&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;5 pachubeKEY=&quot;bfr0eqPG26CdsRgwTOrgIPZV86DRGJr1q9Ept4ZjaJ8&quot;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;6 proceso = subprocess.Popen(&quot;/home/ydirgan/SCRIPTS/pachube/tempRead.ksh&quot;,stdout=subprocess.PIPE,stderr=subprocess.PIPE)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;7 temperatura, errores = proceso.communicate()&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;8 pachube = eeml.Pachube(pachubeURL,pachubeKEY)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;9 pachube.update([eeml.Data(0, temperatura, unit=eeml.Celsius())])&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;10 pachube.put()&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Lines 4 and 5 defines the feed and our &lt;a href=&quot;http://blog.pachube.com/2011/03/breakthrough-new-security-model-for.html&quot;&gt;unique key&lt;/a&gt; needed to authenticate and access the web service.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
In line 6 we execute &amp;nbsp;tempRead.ksh that is a simple script thet execute the filter shown above.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;#!/usr/bin/ksh&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;sensors | grep temp1 | cut -d: -f2 | awk &#39;{print $1}&#39; | sed s/+//g | sed s/&quot;°C&quot;//g&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Line 7 reads the output of the script tempRead.ksh which is a value that will be packed in line 9 using eeml. In our case the UID of our feed is 0, the value is in temperatura variable and the units are in Celsius.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Finally we send the value using the put method in line 10.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
This simple script can be manipulated and modified to send more than one value if we have more than one feed. Every feed is enumerated when we create it (see video). An&amp;nbsp;example&amp;nbsp;of this might be give the following line as parameter of the update() method:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;[eeml.Data(0, temperatura, unit=eeml.Celsius()), eeml.Data(1, cpuUser, unit=eeml.none())]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Using this simple procedure we can update our feeds to have our sensors values up to date on the internet publicly or in a private fashion.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: orange;&quot;&gt;VIDEO:&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&lt;a href=&quot;http://youtu.be/sdkpOfRXItI&quot;&gt;How to send data to a feed on pachube&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
In the next article I am going to show you how to get values from sensors attached to arduino and send them to our feeds.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;color: orange; font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://adirgan.blogspot.com/feeds/4034546231266547676/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://adirgan.blogspot.com/2012/02/how-to-send-data-to-pachube.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/4034546231266547676'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/4034546231266547676'/><link rel='alternate' type='text/html' href='http://adirgan.blogspot.com/2012/02/how-to-send-data-to-pachube.html' title='Internet of things: How to send data to Pachube'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/15931139500048857110</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total><georss:featurename>Calle 152B # 72-2 a 72-100, Bogotá, Departamento de Cundinamarca, Colombia</georss:featurename><georss:point>4.740803690354614 -74.06682014465332</georss:point><georss:box>4.7368476903546144 -74.071755644653322 4.7447596903546136 -74.061884644653318</georss:box></entry><entry><id>tag:blogger.com,1999:blog-5192187322732553132.post-2409988061948509928</id><published>2012-01-29T10:59:00.000-08:00</published><updated>2012-01-29T10:59:11.040-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="communication"/><category scheme="http://www.blogger.com/atom/ns#" term="devices"/><category scheme="http://www.blogger.com/atom/ns#" term="internet"/><category scheme="http://www.blogger.com/atom/ns#" term="pachube"/><title type='text'>Internet of things</title><content type='html'>&lt;span style=&quot;color: orange; font-size: large;&quot;&gt;&lt;b&gt;Abstract&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
In this chapter we will describe pachube. This is a web based tool for showing graphics about values red from devices connected to internet.&lt;br /&gt;
&lt;br /&gt;
This is intended to be short and concise, which will allows to understand the next entry of this blog, when we connect our arduino to this tool for track a temperature sensor.&lt;br /&gt;
&lt;br /&gt;
The information described here was extracted from their URL: www.pachube.com&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: orange; font-size: large;&quot;&gt;&lt;b&gt;What is Pachube anyway?&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Pachube is a realtime data infrastructure platform for the Internet of Things , managing millions of datapoints per day from thousands of individuals, organisations &amp;amp; companies around the world. Pachube&#39;s powerful and scalable infrastructure enables you to build &#39;Internet of Things&#39; products and services, and store, share &amp;amp; discover realtime sensor, energy and environment data from objects, devices &amp;amp; buildings around the world. &lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: orange; font-size: large;&quot;&gt;What allows Pachube?&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Manage realtime sensor &amp;amp; environment data : &lt;/b&gt;&lt;br /&gt;
Pachube is a data brokerage platform for the internet of things , managing millions of datapoints per day from thousands of individuals, organisations &amp;amp; companies around the world. Convenient, secure &amp;amp; economical, Pachube stores, converts &amp;amp; serves data in multiple data formats , which makes it interoperable with both established web protocols &amp;amp; existing construction industry standards. All feeds include contextual metadata (timestamps, geolocation, units, tags) that actually make datastreams valuable.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Graph, monitor &amp;amp; control remote environments : &lt;/b&gt;&lt;br /&gt;
Embed realtime graphs &amp;amp; widgets in your own website. Analyse &amp;amp; process historical data pulled from any public Pachube feed. Send realtime alerts from any datastream to control your own scripts, devices &amp;amp; environments. Out-of-the-box configurable tools include a zoomable graph , a mapping/tracking widget , anaugmented reality viewer , SMS alerts &amp;amp; apps for various smartphones . As soon as something is plugged into Pachube, you&#39;re ready to monitor &amp;amp; control it.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Build mobile &amp;amp; web apps that create value : &lt;/b&gt;&lt;br /&gt;
With a rapid development cycle &amp;amp; dozens of code examples &amp;amp; libraries, Pachube&#39;s simple yet sophisticated&#39;physical-to-virtual&#39; API makes it quick &amp;amp; easy to build applications that add value to networked objects &amp;amp; environments. That&#39;s because real value-creation comes from the applications that are built on top of sensor systems. Pachube handles the scalability &amp;amp; high-availability required for complex data management, so that you are empowered to develop applications that make decision-making more sophisticated.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Share data &amp;amp; create communities : &lt;/b&gt;&lt;br /&gt;
Pachube is built to encourage open ecosystems. Connect electricity meters , weather stations , building management systems , air quality monitors , biosensors , geiger counters — build communities around devices &amp;amp; data collection. While privacy options will soon be available, Pachube&#39;s unique openness promotes growth: most hardware &amp;amp; software libraries &amp;amp; real world applications are being created by its community!&lt;br /&gt;
&lt;br /&gt;
Pachube&#39;s website is a little like YouTube, except that, rather than sharing videos , it enables people to monitor and share real time environmental data from sensors that are connected to the internet. Pachube acts between environments, able both to capture input data (from remote sensors) and serve output data (to remote actuators). Connections can be made between any two environments, facilitating even spontaneous or previously unplanned connections. Apart from being used in physical environments, it also enables people to embed this data in web-pages, in effect to &quot;blog&quot; sensor data. Through the extensive use of metadata, Pachube adds value to physical interconnectivity: it&#39;s not just about datastreams, but about the environments that make up the datastreams.&lt;br /&gt;
&lt;br /&gt;
&lt;img src=&quot;http://community.pachube.com/files/pachube_diagram.jpg&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Pachube makes it simple to build applications, products and services that bridge physical and virtual worlds. With a rapid development cycle (it can take just one line of code to start prototyping ), and a sophisticated development path (working with both web-protocols and data formats that are interoperable with construction industry formats) people have used Pachube to build sensor-logging systems, remote monitoring apps, integrate building management systems, develop geo-tracking systems, create mashups and networked objects and a whole host of other things. For more on what you might do see What can I use Pachube for? .&lt;br /&gt;
&lt;br /&gt;
Apart from CSV and JSON , Pachube also makes use of Extended Environments Markup Language (EEML) , which extends the construction industry protocol IFC. An extensive RESTful API makes it possible to both serve and request data in all formats. Data can be pushed to Pachube using an HTTP PUT request (especially useful for those operating behind firewalls or with non-static URLs) or Pachube can pull data from devices that are able to serve.&lt;br /&gt;
&lt;br /&gt;
There are extensive tutorials and software and hardware libraries and examples available for all sorts of platforms.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Relevant URLs:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
- http://www.pachube.com/ (main website) &lt;br /&gt;
- http://www.economist.com/node/17388392 &quot;The Economist: Special Report on Smart Systems - Augmented Business&quot; &lt;br /&gt;
- http://www.ugotrade.com/2009/01/28/pachube-patching-the-planet-interview... (interview with Pachube&#39;s founder) &lt;br /&gt;
- http://eeml.org/ (Extended Environments Markup Language) &lt;br /&gt;
- http://api.pachube.com/ (technical documentation)</content><link rel='replies' type='application/atom+xml' href='http://adirgan.blogspot.com/feeds/2409988061948509928/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://adirgan.blogspot.com/2012/01/internet-of-things.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/2409988061948509928'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/2409988061948509928'/><link rel='alternate' type='text/html' href='http://adirgan.blogspot.com/2012/01/internet-of-things.html' title='Internet of things'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/15931139500048857110</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192187322732553132.post-1887570246608314207</id><published>2012-01-29T10:34:00.000-08:00</published><updated>2012-01-29T10:34:35.901-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="mailbox-alert"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="serial communication"/><category scheme="http://www.blogger.com/atom/ns#" term="ssmtp"/><category scheme="http://www.blogger.com/atom/ns#" term="thunderbird"/><title type='text'>Email Communication with Arduino (English Version)</title><content type='html'>&lt;div class=&quot;post-body entry-content&quot; id=&quot;post-body-6787098793437202092&quot; style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px; position: relative; width: 576px;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: orange; font-size: medium;&quot;&gt;Abstract&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
In the previous chapter we saw how to communicate with the micro using a chatting client.&amp;nbsp;Very useful if you want to execute commands from a mobile client or from another PC, cities away.&lt;br /&gt;
&lt;br /&gt;
In this chapter we will be exploring how to do it by e-mail, which allows both send and receive information from the micro using a very commonly mean used today.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: orange;&quot;&gt;&lt;b&gt;Arduino code:&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;text-align: left;&quot;&gt;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;a href=&quot;http://dl.dropbox.com/u/14647667/Blogs/CommunicacionSertial-Parte3/serialLed.pde&quot; style=&quot;color: #444444; text-align: left; text-decoration: none;&quot;&gt;led-1.pde&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;color: orange;&quot;&gt;&lt;b&gt;Download:&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;a href=&quot;http://translate.googleusercontent.com/translate_c?hl=en&amp;amp;ie=UTF8&amp;amp;langpair=auto%7Cen&amp;amp;rurl=translate.google.com&amp;amp;tbb=1&amp;amp;twu=1&amp;amp;u=http://dl.dropbox.com/u/14647667/Blogs/CommunicacionSertial-Parte3/led-1.py&amp;amp;usg=ALkJrhhNs8okLUQYAR8Oy5HCCSgR4QZZFg&quot; style=&quot;color: #444444; text-decoration: none;&quot;&gt;SCRIPT&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;color: orange; text-align: left;&quot;&gt;&lt;b&gt;VIDEO:&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;text-align: left;&quot;&gt;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;a href=&quot;http://translate.googleusercontent.com/translate_c?hl=en&amp;amp;ie=UTF8&amp;amp;langpair=auto%7Cen&amp;amp;rurl=translate.google.com&amp;amp;tbb=1&amp;amp;twu=1&amp;amp;u=http://youtu.be/-PRVyOfcsAU&amp;amp;usg=ALkJrhiZMI566IsBZVly9bB4ZiSx2J-JEQ&quot; style=&quot;color: #444444; text-align: left; text-decoration: none;&quot;&gt;E-mail communication with Arduino&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: orange; font-size: medium;&quot;&gt;Communication with the Arduino using the e-mail&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The really interesting part of the email is the ability to format the information we sent from the micro to the PC and then to the user.&amp;nbsp;In this way we can create very good-looking reports to communicate the status of, for example, &amp;nbsp;open status of doors of a house, commercial establishments, factories, offices, etc..&lt;br /&gt;
&lt;br /&gt;
In my search for options that would enable this capability, in a simple way, I found a thunderbird add-on called&amp;nbsp;&lt;a href=&quot;https://addons.mozilla.org/en-us/thunderbird/addon/mailbox-alert/&quot; style=&quot;color: #444444; text-decoration: none;&quot;&gt;Mailbox-Alert&lt;/a&gt;&amp;nbsp;.&amp;nbsp;This add-on installs very easily (see link) and can configure your thunderbird to identify incoming messages, and then run scripts created by us to perform different tasks.&lt;br /&gt;
&lt;br /&gt;
The information contained in this article applies not only to communicate with a microcontroller, but may be used in different situations to automate tasks as required.&amp;nbsp;For example, if we need to ask our server for some event or information about resource utilization.&lt;br /&gt;
&lt;br /&gt;
Let&#39;s see how to configure our components to enable communication via email.&amp;nbsp;Here are the steps to follow to implement this configuration:&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li style=&quot;margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Programmingthe microcontroller using the Arduino IDE&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Create the script that will send commands through the serial port&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Mail-Alert configuration to link a filter to the script indicated below&lt;/li&gt;
&lt;/ol&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSe6qzAY5dHk5c1gdeKmGLLZrrZOuUjzh8Hkaso-Wu_40Ie3aZnab1WBWrmAnG0nFftNeSaQFBqawGevkJN3Jm-mVSvLcQbs5402WI7H6lCBB2luPq6iBmsWHy_Q-E8VNyCqI1nz82goI/s1600/flow.png&quot; imageanchor=&quot;1&quot; style=&quot;color: #444444; margin-left: 1em; margin-right: 1em; text-decoration: none;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;267&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSe6qzAY5dHk5c1gdeKmGLLZrrZOuUjzh8Hkaso-Wu_40Ie3aZnab1WBWrmAnG0nFftNeSaQFBqawGevkJN3Jm-mVSvLcQbs5402WI7H6lCBB2luPq6iBmsWHy_Q-E8VNyCqI1nz82goI/s320/flow.png&quot; style=&quot;-webkit-box-shadow: rgba(0, 0, 0, 0.199219) 0px 0px 0px; background-attachment: initial; background-clip: initial; background-color: #222222; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-color: transparent; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-bottom-style: solid; border-bottom-width: 1px; border-color: initial; border-image: initial; border-left-color: transparent; border-left-style: solid; border-left-width: 1px; border-right-color: transparent; border-right-style: solid; border-right-width: 1px; border-top-color: transparent; border-top-left-radius: 0px; border-top-right-radius: 0px; border-top-style: solid; border-top-width: 1px; border-width: initial; box-shadow: rgba(0, 0, 0, 0.199219) 0px 0px 0px; padding-bottom: 8px; padding-left: 8px; padding-right: 8px; padding-top: 8px; position: relative;&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;The flow chart shown indicates that an incoming message is filtered by thunderbird.&amp;nbsp;In the event that the subject of the message do match the conditions specified in the filter, this will trigger a rule defined in the add-on Mail-Alert that will run the script which makes the interface to the serial port and to the arduino.&amp;nbsp;This script is also capable of responding to the original email sender with the actions taken.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;b&gt;(1) Programming the arduino&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Like the previous article we used a setting of 4 LEDs connected to the arduino.&amp;nbsp;The firmware (software) that we use is the same as in the previous article which can be downloaded&amp;nbsp;&lt;a href=&quot;http://dl.dropbox.com/u/14647667/Blogs/CommunicacionSertial-Parte3/serialLed.pde&quot; style=&quot;color: #444444; text-decoration: none;&quot;&gt;here&lt;/a&gt;&amp;nbsp;.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;b&gt;(2) Python script to interact with Arduino&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;So far we have developed our scripts using ksh, which can run on any linux.&amp;nbsp;To increase portability, in this example we have created a python script which is multiplatform.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;This script takes as parameters the subject content of incoming mail, the sender of the email and the serial port with which it is interacting.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;This script also interacts with a mail client installed on the PCs. In my case I use ssmtp for its simplicity and effectiveness.&amp;nbsp;As I use Ubuntu as my operating system, ssmtp does the job very well and I point out a link where you can get information on how to install it.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;http://translate.googleusercontent.com/translate_c?hl=en&amp;amp;ie=UTF8&amp;amp;langpair=auto%7Cen&amp;amp;rurl=translate.google.com&amp;amp;tbb=1&amp;amp;twu=1&amp;amp;u=http://tombuntu.com/index.php/2008/10/21/sending-email-from-your-system-with-ssmtp/&amp;amp;usg=ALkJrhjLdFLjK5uF5YQy35BAlwj67M_5pw&quot; style=&quot;color: #444444; text-decoration: none;&quot;&gt;Installing and using ssmtp in ubuntu&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Our script uses ssmtp making a call to the operating system using the subprocess library, which allows a fork of an operating system to execute a command, and we can the parameters to that command.&amp;nbsp;The following excerpt shows the routine to send the mail back to sender.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;send_email def (message):&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;try:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;ssmtp = subprocess.Popen ((&#39;/ usr / sbin / ssmtp&#39;, recipient), stdin = subprocess.PIPE)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;except OSError:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;print &#39;I can not begin ssmtp, sothe email was not sent&#39;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;# Pass the contents of the mail through stdin&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;ssmtp.communicate (body% (recipient, sender, message))&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;# Wait until sending mail&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;ssmtp.wait ()&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;b&gt;Download:&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;a href=&quot;http://translate.googleusercontent.com/translate_c?hl=en&amp;amp;ie=UTF8&amp;amp;langpair=auto%7Cen&amp;amp;rurl=translate.google.com&amp;amp;tbb=1&amp;amp;twu=1&amp;amp;u=http://dl.dropbox.com/u/14647667/Blogs/CommunicacionSertial-Parte3/led-1.py&amp;amp;usg=ALkJrhhNs8okLUQYAR8Oy5HCCSgR4QZZFg&quot; style=&quot;color: #444444; text-decoration: none;&quot;&gt;SCRIPT&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;b&gt;(3) Mail-Alert Settings&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;This step is one that allows everything to work.&amp;nbsp;When you get a thunderbird mail through their filters, it can redirect it to a rule defined for Mail-Alert, which will execute the script that interacts with the Arduino.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;(3.1) Create a Mailbox rule-Alert&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;(3.2) Create a filter that redirects to the MailboxAlert rule&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;After setting all the parties involved in the process we can try sending an email to the following features yadirganbot@gmail.com.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;/div&gt;&lt;ul style=&quot;line-height: 1.4; list-style-image: initial; list-style-position: initial; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.5em; padding-bottom: 0px; padding-left: 2.5em; padding-right: 2.5em; padding-top: 0px;&quot;&gt;&lt;li style=&quot;border-bottom-style: none; border-color: initial; border-image: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.25em; padding-left: 0px; padding-right: 0px; padding-top: 0.25em;&quot;&gt;The message must contain the instructions on the subject&lt;/li&gt;
&lt;li style=&quot;border-bottom-style: none; border-color: initial; border-image: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.25em; padding-left: 0px; padding-right: 0px; padding-top: 0.25em;&quot;&gt;The subject must begin with &quot;@, -&amp;gt;&quot; string (without quotes)&lt;/li&gt;
&lt;li style=&quot;border-bottom-style: none; border-color: initial; border-image: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.25em; padding-left: 0px; padding-right: 0px; padding-top: 0.25em;&quot;&gt;You can specify more than one command in the subject separated by spaces&lt;/li&gt;
&lt;li style=&quot;border-bottom-style: none; border-color: initial; border-image: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.25em; padding-left: 0px; padding-right: 0px; padding-top: 0.25em;&quot;&gt;The commands supported are:&lt;/li&gt;
&lt;ul style=&quot;line-height: 1.4; list-style-image: initial; list-style-position: initial; list-style-type: disc; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.5em; padding-bottom: 0px; padding-left: 2.5em; padding-right: 2.5em; padding-top: 0px;&quot;&gt;&lt;li style=&quot;border-bottom-style: none; border-color: initial; border-image: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.25em; padding-left: 0px; padding-right: 0px; padding-top: 0.25em;&quot;&gt;ledon, ledoff (Turn on all LEDs)&lt;/li&gt;
&lt;li style=&quot;border-bottom-style: none; border-color: initial; border-image: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.25em; padding-left: 0px; padding-right: 0px; padding-top: 0.25em;&quot;&gt;ledNon, ledNoff: (1 &amp;lt;N &amp;lt;4) (Light a LED at a time)&lt;/li&gt;
&lt;li style=&quot;border-bottom-style: none; border-color: initial; border-image: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.25em; padding-left: 0px; padding-right: 0px; padding-top: 0.25em;&quot;&gt;titilar (Run all LEDs flashing)&lt;/li&gt;
&lt;li style=&quot;border-bottom-style: none; border-color: initial; border-image: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.25em; padding-left: 0px; padding-right: 0px; padding-top: 0.25em;&quot;&gt;secuencia1 (Run an LED chaser from left to right)&lt;/li&gt;
&lt;li style=&quot;border-bottom-style: none; border-color: initial; border-image: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.25em; padding-left: 0px; padding-right: 0px; padding-top: 0.25em;&quot;&gt;secuencia2 (Run an LED chaser from right to left)&lt;/li&gt;
&lt;li style=&quot;border-bottom-style: none; border-color: initial; border-image: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.25em; padding-left: 0px; padding-right: 0px; padding-top: 0.25em;&quot;&gt;pN, N&amp;gt; 0 integer or decimal (indicating a pause in milliseconds)&lt;/li&gt;
&lt;li style=&quot;border-bottom-style: none; border-color: initial; border-image: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.25em; padding-left: 0px; padding-right: 0px; padding-top: 0.25em;&quot;&gt;xN, N&amp;gt; = 1 (to repeat N times a command)&lt;/li&gt;
&lt;/ul&gt;&lt;/ul&gt;&lt;div&gt;In this example we see how to send a sequence of commands to arduino to yadirganbot@gmail.com.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;To: yadirganbot@gmail.com&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;Subject: @,-&amp;gt; x3 secuencia1 p.5 &amp;nbsp;x3 secuencia2 p.5 titilar p.5 ledon p2 ledoff&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Thunderbird, through a filter, detects that sequence @,-&amp;gt; is in the subject of the mail and sends it to the rule created in Mailbox-Alert.&amp;nbsp;Mailbox Alert shows up a pop-up indicating the sender and the message and also run the following command:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;/ home/ydirgan/SCRIPTS/mailboxAlert/led-1.py %subject %sender /dev/ttyACM0&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
in which we are passing as parameters &amp;nbsp;the email subject, which contains the commands.The sender and finally the serial port where the arduino is connected to.&lt;br /&gt;
&lt;br /&gt;
The script runs led-1.py sending serial commands, logging at led-1.log and sending back a message to the sender via ssmtp.&lt;br /&gt;
&lt;br /&gt;
In the video you can see the life-cycle of communication with the arduino.&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;b&gt;VIDEO:&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;a href=&quot;http://translate.googleusercontent.com/translate_c?hl=en&amp;amp;ie=UTF8&amp;amp;langpair=auto%7Cen&amp;amp;rurl=translate.google.com&amp;amp;tbb=1&amp;amp;twu=1&amp;amp;u=http://youtu.be/-PRVyOfcsAU&amp;amp;usg=ALkJrhiZMI566IsBZVly9bB4ZiSx2J-JEQ&quot; style=&quot;color: #444444; text-decoration: none;&quot;&gt;email communication with Arduino&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;post-footer&quot; style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 1.6; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 1.5em;&quot;&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adirgan.blogspot.com/feeds/1887570246608314207/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://adirgan.blogspot.com/2012/01/email-communication-with-arduino.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/1887570246608314207'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/1887570246608314207'/><link rel='alternate' type='text/html' href='http://adirgan.blogspot.com/2012/01/email-communication-with-arduino.html' title='Email Communication with Arduino (English Version)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/15931139500048857110</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSe6qzAY5dHk5c1gdeKmGLLZrrZOuUjzh8Hkaso-Wu_40Ie3aZnab1WBWrmAnG0nFftNeSaQFBqawGevkJN3Jm-mVSvLcQbs5402WI7H6lCBB2luPq6iBmsWHy_Q-E8VNyCqI1nz82goI/s72-c/flow.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192187322732553132.post-6888358028648653644</id><published>2012-01-29T08:45:00.000-08:00</published><updated>2012-01-29T08:45:34.899-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="centerim"/><category scheme="http://www.blogger.com/atom/ns#" term="communication"/><category scheme="http://www.blogger.com/atom/ns#" term="messenger"/><category scheme="http://www.blogger.com/atom/ns#" term="serial port"/><title type='text'>Communication with Arduino using chat client (english  version)</title><content type='html'>&lt;div class=&quot;post-body entry-content&quot; id=&quot;post-body-4440692986606409853&quot; style=&quot;position: relative; width: 576px;&quot;&gt;&lt;b style=&quot;line-height: 1.4;&quot;&gt;&lt;span style=&quot;color: orange; font-size: medium;&quot;&gt;Abstract&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;line-height: 1.4;&quot;&gt;In the previous article we saw the basic theory of how to communicate with the microcontroller using the serial port of your PC.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;line-height: 1.4;&quot;&gt;In this article we look at the basics to make the micro responds to commands sent using an instant messaging client, email, or twitter Pachube.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #eeeeee; line-height: 1.4;&quot;&gt;&lt;b&gt;Downloads:&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://dl.dropbox.com/u/14647667/Blogs/ComunicacionSerial-Parte2/serialLed.pde&quot; style=&quot;color: #444444; line-height: 1.4; text-align: left; text-decoration: none;&quot;&gt;serialLed.pde&lt;/a&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;,&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://translate.googleusercontent.com/translate_c?hl=en&amp;amp;ie=UTF8&amp;amp;langpair=auto%7Cen&amp;amp;rurl=translate.google.com&amp;amp;tbb=1&amp;amp;twu=1&amp;amp;u=http://dl.dropbox.com/u/14647667/Blogs/ComunicacionSerial-Parte2/led1log.py&amp;amp;usg=ALkJrhh15bmQQsLK_pF-S1atPEyrow4zSQ&quot; style=&quot;color: #444444; line-height: 1.4; text-align: left; text-decoration: none;&quot;&gt;led1log.py&lt;/a&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;,&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://dl.dropbox.com/u/14647667/Blogs/ComunicacionSerial-Parte2/led-1.ksh&quot; style=&quot;color: #444444; line-height: 1.4; text-align: left; text-decoration: none;&quot;&gt;led-1.ksh&lt;/a&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;,&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://translate.googleusercontent.com/translate_c?hl=en&amp;amp;ie=UTF8&amp;amp;langpair=auto%7Cen&amp;amp;rurl=translate.google.com&amp;amp;tbb=1&amp;amp;twu=1&amp;amp;u=http://dl.dropbox.com/u/14647667/Blogs/ComunicacionSerial-Parte2/external&amp;amp;usg=ALkJrhj2SD7lHrVVw_qKQjTRGyMN0aMoew&quot; style=&quot;color: #444444; line-height: 1.4; text-align: left; text-decoration: none;&quot;&gt;external&lt;/a&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #eeeeee; line-height: 1.4;&quot;&gt;&lt;b&gt;VIDEO:&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://translate.googleusercontent.com/translate_c?hl=en&amp;amp;ie=UTF8&amp;amp;langpair=auto%7Cen&amp;amp;rurl=translate.google.com&amp;amp;tbb=1&amp;amp;twu=1&amp;amp;u=http://www.youtube.com/watch%3Fv%3DwLiQauM_A4E&amp;amp;usg=ALkJrhhBXXDZBtiKO1Cf7ov3Fr_06ysvVw&quot; style=&quot;color: #444444; line-height: 1.4; text-decoration: none;&quot;&gt;Step by Step&lt;/a&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: orange; font-size: medium;&quot;&gt;&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;b&gt;Communication with Arduino using chat client&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;line-height: 1.4;&quot;&gt;We have seen how to send or receive information to and from the microcontroller using the serial port.&amp;nbsp;The next step is to use the micro to react to commands sent using our PC or analyze and react to information received from the micro.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;line-height: 1.4;&quot;&gt;In a first study how to react to micro according to the orders that we can send to serial port&amp;nbsp;we initially send orders directly through the port by using the direct method, but the idea is to use a interface.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;line-height: 1.4;&quot;&gt;We will be working with some type of communication interfacing such as a chat client, email, twitter or Pachube to name the four that we will explore in this and the next 3 entries.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;line-height: 1.4;&quot;&gt;&lt;span style=&quot;color: orange; font-size: medium;&quot;&gt;Communication with micro via messenger&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;line-height: 1.4;&quot;&gt;Looking extensively on the Web for free software to use as a chat client I finally found&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;line-height: 19px;&quot;&gt;CenterIM&lt;/span&gt;&lt;span style=&quot;line-height: 19px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;This application is a lightweight chat client, which can be configured with a variety of public accounts as a messenger, yahoo, etc..&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: orange; line-height: 1.4;&quot;&gt;&lt;b&gt;REF1:&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://translate.googleusercontent.com/translate_c?hl=en&amp;amp;ie=UTF8&amp;amp;langpair=auto%7Cen&amp;amp;rurl=translate.google.com&amp;amp;tbb=1&amp;amp;twu=1&amp;amp;u=http://www.centerim.org/&amp;amp;usg=ALkJrhirYRlQq0hjlzjfbavXjVXfRf0HWQ&quot; style=&quot;color: #444444; line-height: 1.4; text-decoration: none;&quot;&gt;CenterIM home&lt;/a&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: orange; line-height: 1.4;&quot;&gt;&lt;b&gt;REF2:&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://translate.googleusercontent.com/translate_c?hl=en&amp;amp;ie=UTF8&amp;amp;langpair=auto%7Cen&amp;amp;rurl=translate.google.com&amp;amp;tbb=1&amp;amp;twu=1&amp;amp;u=http://www.webupd8.org/2009/06/lightweight-im-client-centerim-runs-in.html&amp;amp;usg=ALkJrhjcZlrs4-BbUw_5rps4zDmMc3kc1A&quot; style=&quot;color: #444444; line-height: 1.4; text-decoration: none;&quot;&gt;Installation CenterIM&lt;/a&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;line-height: 1.4;&quot;&gt;In the previous references &amp;nbsp;you can access the product home and a very good article on how to install it ubuntu.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;line-height: 1.4;&quot;&gt;The documentation found in reference 1 is very broad and can be used to initially configure the package.&amp;nbsp;In my case I set it up with an account especially created for this experiment.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;line-height: 1.4;&quot;&gt;As a chat client, centerIM works like any other messaging client, but with additional features that fits well for our purpose.&amp;nbsp;CenterIM allows us to program scripts to execute tasks according to the content of incoming messages.With this capability you can program different behaviors of how to send commands to the microcontroller via serial port.&amp;nbsp;This allows us to communicate from the messenger to the home computer to perform some tasks such the&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;activation of an alarm, turn on or off lights and appliances, and so on.&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;line-height: 1.4;&quot;&gt;This configuration must be done using a script that should be copied at&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: magenta; line-height: 1.4;&quot;&gt;&lt;i&gt;$HOME/.centerim&lt;/i&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;and whose name must be&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: magenta; line-height: 1.4;&quot;&gt;&lt;i&gt;external.&lt;/i&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;line-height: 1.4;&quot;&gt;The format of the external script is very simple.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d; line-height: 1.4;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d; line-height: 1.4;&quot;&gt;% Action Action to take according to the following conditions&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d; line-height: 1.4;&quot;&gt;msg event&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d; line-height: 1.4;&quot;&gt;# Reacts only to messages&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d; line-height: 1.4;&quot;&gt;proto msn&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d; line-height: 1.4;&quot;&gt;# Only for the protocol messenger&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d; line-height: 1.4;&quot;&gt;online status&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d; line-height: 1.4;&quot;&gt;# It only if the status of the account is online&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d; line-height: 1.4;&quot;&gt;stdin stdout options&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d; line-height: 1.4;&quot;&gt;# ..&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #38761d; line-height: 1.4;&quot;&gt;external commands (below) read from&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d; line-height: 1.4;&quot;&gt;# Stdin, stdout it&#39;s output is sent as a response&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d; line-height: 1.4;&quot;&gt;# To a remote user&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d; line-height: 1.4;&quot;&gt;% Exec&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d; line-height: 1.4;&quot;&gt;msg = `cat`&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d; line-height: 1.4;&quot;&gt;echo $(/ home/ydirgan/.centerim/commTest.ksh &quot;$msg&quot;)&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;line-height: 1.4;&quot;&gt;% Exec redirects the message to a simple script that just returns the message via the same mean.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #38761d; line-height: 1.4;&quot;&gt;# CommTest.ksh&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d; line-height: 1.4;&quot;&gt;#! /usr/ bin/ksh&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d; line-height: 1.4;&quot;&gt;msg = `echo $ 1 | tr az AZ`;&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d; line-height: 1.4;&quot;&gt;printf &amp;nbsp;&quot;arduino-1 command received: $msg&quot;;&lt;/span&gt;&lt;span style=&quot;line-height: 1.4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;line-height: 1.4; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;line-height: 1.4; text-align: left;&quot;&gt;Upon receiving the message, CenterIM script redirects the output to commTest.ksh, it receives the title of the email as a parameter which we convert to uppercase and return it to the stdout via CenterIM (email).&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;line-height: 1.4; text-align: left;&quot;&gt;From this simple example we can model a small script to turn on/off 4 LEDs connected to the digital pins 0 .. 3 of our teensy (arduino compatible microctroller).&lt;br /&gt;
&lt;br /&gt;
Here are the steps that we have to follow:&lt;br /&gt;
&lt;ol&gt;&lt;li style=&quot;margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Creation of an arduino script that responds to commands recieved via serial (From the microcontroller)&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Creation of a logging script to log serial port output (from the PC)&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Creation of a script that is called from &quot;external&quot;, which contains the execution logic&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Creation of the script &quot;external&quot; to be used by CenterIM&lt;/li&gt;
&lt;/ol&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;b&gt;(1) Script for the Microcontroller&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;The script responds to commands received by the teensy serial port (like the Arduino micro).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;The script turns on or off a LED on pin n (1 &amp;lt;= n &amp;lt;= 4). It waits for a character that is available on the serial port.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;serial input = 1:LED 1 will be turned on&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;serial input = 2:LED 1 will be turned off&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;serial input = 3: LED 2 will be turned on&lt;/div&gt;&lt;div style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;serial input = 4: &lt;span style=&quot;font-size: 13px;&quot;&gt;LED 2&amp;nbsp;&lt;/span&gt;will be turned off&lt;/div&gt;&lt;div style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;serial input = 5: 3 LED&amp;nbsp;&amp;nbsp;will be turned on&lt;/div&gt;&lt;div style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;serial input = 6: 3 LED&amp;nbsp;will be turned off&lt;/div&gt;&lt;div style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;serial input = 7: 4 LED&amp;nbsp;&amp;nbsp;will be turned on&lt;/div&gt;&lt;div style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;serial input = 8: 4 LED&amp;nbsp;will be turned off&lt;/div&gt;&lt;div style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;Once you download the program it must be loaded it into the arduino.&amp;nbsp;Once loaded you can test the behavior directly interacting with the serial port, as seen in the video at the end of the article.&lt;/div&gt;&lt;span style=&quot;background-color: #141414; color: orange; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;b&gt;&lt;br class=&quot;Apple-interchange-newline&quot; /&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;b&gt;Download:&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;a href=&quot;http://dl.dropbox.com/u/14647667/Blogs/ComunicacionSerial-Parte2/serialLed.pde&quot; style=&quot;color: #444444; text-decoration: none;&quot;&gt;serialLed.pde&lt;/a&gt;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot; /&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;b&gt;(2) logging script&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot; /&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;This script is intended to run on background and the purpose of it is to copy each line of output of /dev/ttyACM0 to a file.&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot; /&gt;&lt;br style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot; /&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;ydirgan@pragma-systems:~/scripts/$CenterIM led1log.py /dev/ttyACM0 &amp;amp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;b&gt;Download:&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;a href=&quot;http://translate.googleusercontent.com/translate_c?hl=en&amp;amp;ie=UTF8&amp;amp;langpair=auto%7Cen&amp;amp;rurl=translate.google.com&amp;amp;tbb=1&amp;amp;twu=1&amp;amp;u=http://dl.dropbox.com/u/14647667/Blogs/ComunicacionSerial-Parte2/led1log.py&amp;amp;usg=ALkJrhh15bmQQsLK_pF-S1atPEyrow4zSQ&quot; style=&quot;color: #444444; text-decoration: none;&quot;&gt;led1log.py&lt;/a&gt;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot; /&gt;&lt;div style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;b&gt;(3) Script with the execution logic&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot; /&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;The third script allows you to execute sequences of commands that needs to be sent to the arduino.&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;With the limited instructions that are defined on the micro script we can actually increase the funcionalities using this script.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot; /&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;In this program we can turn on or off individual LEDs, but also we can light them all, turn off them all, make a blink or running a sequence.&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;All this using the primitives that we have programmed into the micro.&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot; /&gt;&lt;br style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot; /&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;In addition to the instruction set defined, we have programmed an instruction to obtain information of using by typing HELP from the chat window, and the result becomes:&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot; /&gt;&lt;br style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot; /&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;arduino-1: This is a finite state machine to interact with an Arduino microcontroller type.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;Its use is intended only as an example.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;The microcontroller re-weight when it recognizes the command to execute.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;They have 4 LEDs on and off each of them.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;The commands you can use are: ledNon, where n is the number of LEDs (1 &amp;lt;= N &amp;lt;= 4).&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;ledNoff, where n is the number of LEDs (1 &amp;lt;= N &amp;lt;= 4).&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;ledon, all LEDs will light.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;ledoff, all the LEDs go out.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;Tilite, all LED&#39;s will flash 20 times.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;stream1, all the LEDs light up in sequence (LED chaser) from left to right.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;stream2, all the LEDs light up in sequence (LED chaser) from right to left.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;help shows this help.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot; /&gt;&lt;br style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot; /&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;b&gt;Download:&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;a href=&quot;http://dl.dropbox.com/u/14647667/Blogs/ComunicacionSerial-Parte2/led-1.ksh&quot; style=&quot;color: #444444; text-decoration: none;&quot;&gt;led-1.ksh&lt;/a&gt;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot; /&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;b&gt;(4) external script to CenterIM&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot; /&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;Finally, the script that runs CenterIM when we send a message.&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;This will trigger the execution of the script led-1.ksh that will be sending our commands to arduino using the serial port.&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;The microcontroller will process it and respond according to the script.&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot; /&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;b&gt;Download:&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;a href=&quot;http://translate.googleusercontent.com/translate_c?hl=en&amp;amp;ie=UTF8&amp;amp;langpair=auto%7Cen&amp;amp;rurl=translate.google.com&amp;amp;tbb=1&amp;amp;twu=1&amp;amp;u=http://dl.dropbox.com/u/14647667/Blogs/ComunicacionSerial-Parte2/external&amp;amp;usg=ALkJrhj2SD7lHrVVw_qKQjTRGyMN0aMoew&quot; style=&quot;color: #444444; text-decoration: none;&quot;&gt;external&lt;/a&gt;&lt;/span&gt;&lt;span style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot; /&gt;&lt;div style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;Finally run CenterIM from our terminal to activate the robot.&lt;/div&gt;&lt;div style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;The video to show the sequence of steps is as follows:&lt;/div&gt;&lt;div style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;b&gt;VIDEO:&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;a href=&quot;http://translate.googleusercontent.com/translate_c?hl=en&amp;amp;ie=UTF8&amp;amp;langpair=auto%7Cen&amp;amp;rurl=translate.google.com&amp;amp;tbb=1&amp;amp;twu=1&amp;amp;u=http://www.youtube.com/watch%3Fv%3DwLiQauM_A4E&amp;amp;usg=ALkJrhhBXXDZBtiKO1Cf7ov3Fr_06ysvVw&quot; style=&quot;color: #444444; text-decoration: none;&quot;&gt;Step by Step&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adirgan.blogspot.com/feeds/6888358028648653644/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://adirgan.blogspot.com/2012/01/communication-with-arduino-using-chat.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/6888358028648653644'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/6888358028648653644'/><link rel='alternate' type='text/html' href='http://adirgan.blogspot.com/2012/01/communication-with-arduino-using-chat.html' title='Communication with Arduino using chat client (english  version)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/15931139500048857110</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192187322732553132.post-4016007506311549119</id><published>2012-01-29T08:07:00.000-08:00</published><updated>2012-01-29T08:09:48.688-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="communication"/><category scheme="http://www.blogger.com/atom/ns#" term="interaction"/><title type='text'>Serial Communication with Arduino (English Version)</title><content type='html'>&lt;b style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;span style=&quot;color: orange; font-size: medium;&quot;&gt;Abstract&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;post-header&quot; style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 1.6; margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div class=&quot;post-header-line-1&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;post-body entry-content&quot; id=&quot;post-body-6412417046662723624&quot; style=&quot;background-color: #141414; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; line-height: 18px; position: relative; width: 576px;&quot;&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;One of the main advantages of a micro is the chance we have of communicating with it via serial port.&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;In this article, and next we will have an idea of ​​what we can do, and some of the tools I have found interesting to interact with a microcontrollers, involving internet ...&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;Unless a micro is programmed with a standalone implementation, ie, that its operation is limited to actions that do not depend on external interaction (beyond digital or analog inputs) is not necessary to implement the mechanisms that this article describes.&amp;nbsp;It is true that many applications do not require microcontrollers to get outside the inner environment, but it is increasingly common to think of communication as a tool of interaction with applications designed for these environments.&amp;nbsp;Consider the following example.&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: orange; font-size: medium;&quot;&gt;...&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: orange; font-size: medium;&quot;&gt;Arduino microcontroller communication type&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;If we have a house with panoramic windows (these that open by sliding horizontally), such that a person can enter smoothly through when opened, and we often like to go on vacation, we will have a security problem.&amp;nbsp;The probability of breaking into our home at that time in the house alone is very high.&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;For someone who wants to design your security system, first of all probably think of placing motion sensors to trigger a very noisy alarm when an intrusion into the residence is detected.This may be a solution, but the alarm will alert only to the immediate surroundings of the house, and intruders.&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;But we can also think of a silent security system emiting an alarm message to the house&#39;s owner via the Internet, sending a text message alert to a receiving means, either email, client chat (IM) or twitter!.&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;Another example of remote communication is the possibility of creating a system that could &amp;nbsp;controls lights or appliances in our home. These can be automated from the microcontroller defining scheduled events for turning on or off lights, moving a sun-oriented solar cell efficiently, to power a window for the entry of light according to ambient brightness or just turn on air conditioning in our room near the hour of our arrival.&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;With this last example, what if we come home early?.&amp;nbsp;We could communicate with our microcontroller using the cellular using our messenger by sending a message like the following:&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;AC: turn on&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;In this way, and through the proper software, this message can be received and executed online.&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;To perform tasks like explained above, we must start from the simple to the complex.&amp;nbsp;The first thing to know is that with microcontrollers like the Arduino, pinguino, teensy, etc..&amp;nbsp;we can communicate to a server via&amp;nbsp;&lt;a href=&quot;http://translate.googleusercontent.com/translate_c?hl=en&amp;amp;ie=UTF8&amp;amp;langpair=auto%7Cen&amp;amp;rurl=translate.google.com&amp;amp;tbb=1&amp;amp;twu=1&amp;amp;u=http://en.wikipedia.org/wiki/Serial_communication&amp;amp;usg=ALkJrhiXDbL6xKWCrw5yQkJjtN5L_MObGg&quot; style=&quot;color: #444444; text-decoration: none;&quot;&gt;serial&lt;/a&gt;&amp;nbsp;port&amp;nbsp;.&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;With&amp;nbsp;&lt;a href=&quot;http://translate.googleusercontent.com/translate_c?hl=en&amp;amp;ie=UTF8&amp;amp;langpair=auto%7Cen&amp;amp;rurl=translate.google.com&amp;amp;tbb=1&amp;amp;twu=1&amp;amp;u=http://www.arduino.cc/&amp;amp;usg=ALkJrhgWE4VKQDY85eYpoPvoyxWrZpN-NQ&quot; style=&quot;color: #444444; text-decoration: none;&quot;&gt;arduino&lt;/a&gt;&amp;nbsp;or&amp;nbsp;&lt;a href=&quot;http://translate.googleusercontent.com/translate_c?hl=en&amp;amp;ie=UTF8&amp;amp;langpair=auto%7Cen&amp;amp;rurl=translate.google.com&amp;amp;tbb=1&amp;amp;twu=1&amp;amp;u=http://www.pjrc.com/teensy/&amp;amp;usg=ALkJrhgqWT_l_P6bGFnGj8oQzNWSzuah8w&quot; style=&quot;color: #444444; text-decoration: none;&quot;&gt;teensy&lt;/a&gt;&amp;nbsp;serial communication is established via USB interface from which we have to connect the microcontroller to the computer.&amp;nbsp;Once serial port is initialized from the microcontroller environments, linux / unix directory is mapped to / dev / ttyXXXn that will give us the opportunity to send or receive information.&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;The following code, using Arduino, defines the sequential output of a message to our computer&#39;s serial port.&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;int i = 0;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;void setup ()&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;{&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp;Serial.begin (9600);&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;}&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;void loop ()&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;{&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp;Serial.print (&quot;test message&quot;);&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp;Serial.println (++ i);&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp;delay (1000);&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;}&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;In block setup () we initialize the serial port to 9600 baud with Serial.begin (9600).&amp;nbsp;In the block loop () we send the message via serial port followed by a number sequencially updated by ++ i.&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;From the computer we will see this output if we properly interrogate the port mapping in /dev/ttyACMn.Where n&amp;gt; = 0.&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;For this example the port was mapped to / dev/ttyACM0.&amp;nbsp;In my case I use ubuntu, but for any Linux / MAC should be very similar.&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;When the microcontroller is plugged into any USB port on our computer it can be accessed via command line from a terminal or through a program made for this purpose.&amp;nbsp;A third option is to create our own program of reading and / or writing to the serial port.&amp;nbsp;This last option is appropriate if we want to interact withthe microcontroller to get information or instruct it to perform any action.&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;For our simple example, we can initially examine the&lt;span style=&quot;font-size: 13px;&quot;&gt;&amp;nbsp;serial port using the tool that comes with the Arduino IDE or through gtkterminal or minicom.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: orange;&quot;&gt;VIDEO:&amp;nbsp;&lt;a href=&quot;http://translate.googleusercontent.com/translate_c?hl=en&amp;amp;ie=UTF8&amp;amp;langpair=auto%7Cen&amp;amp;rurl=translate.google.com&amp;amp;tbb=1&amp;amp;twu=1&amp;amp;u=http://www.youtube.com/watch%3Fv%3DBOLskuY025I&amp;amp;usg=ALkJrhgdDfW87Vep_RD7eS0JU6yNwokCZA&quot; style=&quot;color: #444444; text-decoration: none;&quot;&gt;&amp;nbsp;Serial Communication 1&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;From the microcontroller you can also read from the serial port so there is the posibility to make decisions and run actions according to the input.&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;The following program simply read the serial input and return the string obtained by detecting the end of line.&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;char character;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;byte i = 0;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;char string [100];&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;void setup ()&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;{&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;Serial.begin (9600);&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;}&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;void loop ()&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;{&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;if (Serial.available ())&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;{&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px;&quot;&gt;&lt;i style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;caracter=&lt;i&gt;Serial.read();&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;if (character == 10)&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;{&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;string [i ++]=&#39; \ 0 &#39;;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;i = 0;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;Serial.println (string);&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;}&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;else&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;string [i ++] = character;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;}&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;}&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;In setup() block we initialize the port, then in the loop() &amp;nbsp;block we check for the port buffer using Serial.available ().&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;If there are characters available Serial.read sequentially reads each one.&amp;nbsp;If we detect the end of line caracter (10) we add it to the string and reset the counter, sending back the string to the port.&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;If the character received is not an end of line (10) then we attach it to the end of the string updating the counter.&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: orange;&quot;&gt;VIDEO:&amp;nbsp;&lt;a href=&quot;http://translate.googleusercontent.com/translate_c?hl=en&amp;amp;ie=UTF8&amp;amp;langpair=auto%7Cen&amp;amp;rurl=translate.google.com&amp;amp;tbb=1&amp;amp;twu=1&amp;amp;u=http://www.youtube.com/watch%3Fv%3DncLGY8X3OHw&amp;amp;usg=ALkJrhhWO3Gyn-5ZHTV7OgCY39osDE64Ag&quot; style=&quot;color: #444444; text-decoration: none;&quot;&gt;Serial Communication 2&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;Now let&#39;s see how to use the latter program to bring to power on or off to the air conditioning in the second example shown in this article.&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;# Include string.h&lt;/span&gt;&amp;nbsp;&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;# Define ON 1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;# Define OFF 0&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;char caracter;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;byte i = 0;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;char string [100];&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;AC_Action void (int action)&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;{&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;if (action == ON)&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;{&lt;/span&gt;&amp;nbsp;&lt;/string.h&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;Serial.println (&quot;Turning AC ON ...&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;/string.h&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #eeeeee;&quot;&gt;/ / Action to light&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;/string.h&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #eeeeee;&quot;&gt;/ / Wait for result&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;delay (500);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;Serial.println (&quot;Air conditioning was activated ... Status OK&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;if (action == OFF)&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;{&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;Serial.println (&quot;Turning OFF AC ...&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;/string.h&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #eeeeee;&quot;&gt;/ / Shutdown action&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;/string.h&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;/&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;/ Wait for result&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;delay (500);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;Serial.println (&quot;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;Air conditioning was deactivated&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;... Status OK&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;void setup ()&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;{&lt;/span&gt;&amp;nbsp;&lt;/string.h&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;Serial.begin (9600);&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;void loop ()&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;{&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;if (Serial.available ())&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;{&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;caracter= Serial.read();&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;if (caracter == 10)&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;string [i ++]=&#39; \ 0 &#39;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;i = 0;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;if (strcmp (string, &quot;AC: On&quot;))&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;AC_Action (ON);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;if (strcmp (string, &quot;AC: OFF&quot;))&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;AC_Action (OFF);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;string [i + +] = caracter;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
We have created a procedure depending on the action parameter to turn on or off the air conditioning, assuming we have a device that controls the AC connected to the microcontroller.&amp;nbsp;In our case the microcontroller, via serial port, return the message on and off accordingly.&lt;br /&gt;
&lt;br /&gt;
The block loop () maintains the same pattern, except that when you match a specific string runs AC_Action function () passing the parameter set ON or OFF at the beginning of the program.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: orange;&quot;&gt;VIDEO:&amp;nbsp;&lt;a href=&quot;http://translate.googleusercontent.com/translate_c?hl=en&amp;amp;ie=UTF8&amp;amp;langpair=auto%7Cen&amp;amp;rurl=translate.google.com&amp;amp;tbb=1&amp;amp;twu=1&amp;amp;u=http://www.youtube.com/watch%3Fv%3D-ahIsMCD-Ak&amp;amp;usg=ALkJrhjdTl_OKM0cb-uW4R-zl68T86rKGQ&quot; style=&quot;color: #444444; text-decoration: none;&quot;&gt;Serial Communication 3&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The next step will be communicating ourselves from outside to PC using several means to interact with the microcontroller.&lt;br /&gt;
&lt;br /&gt;
In future articles we will continue to explore possibilities for communication, interaction and execution.&lt;/string.h&gt;&lt;/div&gt;&lt;div style=&quot;color: white; font-size: 13px;&quot;&gt;&lt;string.h&gt;&lt;br /&gt;
&lt;/string.h&gt;&lt;/div&gt;&lt;div style=&quot;clear: both; color: white; font-size: 13px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;post-footer&quot; style=&quot;background-color: #141414; color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 1.6; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 1.5em;&quot;&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adirgan.blogspot.com/feeds/4016007506311549119/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://adirgan.blogspot.com/2012/01/serial-communication-with-arduino.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/4016007506311549119'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/4016007506311549119'/><link rel='alternate' type='text/html' href='http://adirgan.blogspot.com/2012/01/serial-communication-with-arduino.html' title='Serial Communication with Arduino (English Version)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/15931139500048857110</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192187322732553132.post-6787098793437202092</id><published>2012-01-21T09:33:00.000-08:00</published><updated>2012-01-29T10:35:54.654-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="communication"/><category scheme="http://www.blogger.com/atom/ns#" term="ksh"/><category scheme="http://www.blogger.com/atom/ns#" term="mailbox-alert"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="serial"/><category scheme="http://www.blogger.com/atom/ns#" term="thunderbird"/><title type='text'>Comunicación vía email con Arduino</title><content type='html'>&lt;span style=&quot;color: orange; font-size: large;&quot;&gt;&lt;b&gt;Abstract&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
(&lt;a href=&quot;http://adirgan.blogspot.com/2012/01/email-communication-with-arduino.html&quot;&gt;go to English Version&lt;/a&gt;)&lt;br /&gt;
&lt;br /&gt;
En el capítulo anterior vimos como comunicarnos con el micro a través del chat de msn. Muy útil si queremos ejecutar órdenes &amp;nbsp;desde un cliente móvil o desde otro PC a ciudades de distancia. ref:&amp;nbsp;&lt;a href=&quot;http://adirgan.blogspot.com/2012/01/comunicacion-con-microcontroladores_15.html&quot;&gt;Comunicación con microControladores tipo Arduino. Enviando órdenes al micro a través del chat, email, pachube o twitter&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
En este capítulo exploraremos la forma de hacerlo por medio del correo electrónico, lo cual permite tanto enviar, como recibir información del micro por un medio utilizado muy comúnmente en la actualidad.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: orange;&quot;&gt;Código Arduino:&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&lt;span style=&quot;text-align: left;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://dl.dropbox.com/u/14647667/Blogs/CommunicacionSertial-Parte3/serialLed.pde&quot; style=&quot;text-align: left;&quot;&gt;led-1.pde&lt;/a&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: orange;&quot;&gt;Download:&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&lt;a href=&quot;http://dl.dropbox.com/u/14647667/Blogs/CommunicacionSertial-Parte3/led-1.py&quot;&gt;SCRIPT&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;color: orange; text-align: left;&quot;&gt;&lt;b&gt;VIDEO:&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;text-align: left;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://youtu.be/-PRVyOfcsAU&quot; style=&quot;text-align: left;&quot;&gt;Comunicación por email con Arduino&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: orange; font-size: large;&quot;&gt;&lt;b&gt;Comunicación con el Arduino vía correo Electrónico&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Lo realmente interesante del email es la capacidad de darle formato a la información que podemos enviar desde el micro al PC y luego al usuario. De esta forma podemos crear reportes de muy buen aspecto para informar del status de, por ejemplo, los puntos de seguridad de una casa particular, establecimiento comercial, fábrica, oficina, etc.&lt;br /&gt;
&lt;br /&gt;
Dentro de mi búsqueda por opciones que permitiesen esta capacidad, de manera simple, encontré un add-on de thunderbird llamado &lt;a href=&quot;https://addons.mozilla.org/en-us/thunderbird/addon/mailbox-alert/&quot;&gt;Mailbox-Alert&lt;/a&gt;. Este add-on se instala de forma muy sencilla (ver enlace) y permite configurar nuestro thunderbird para identificar mensajes entrantes, para luego ejecutar scripts creados por nosotros para ejecutar diferentes tareas.&lt;br /&gt;
&lt;br /&gt;
La información contenida en este artículo no solo aplica para la comunicación con un microcontrolador, sino que puede ser empleada en diversas situaciones para automatizar tareas que requiramos. Por ejemplo, si necesitamos interrogar nuestro servidor por algún evento, o información de utilización del mismo.&lt;br /&gt;
&lt;br /&gt;
Por lo pronto veamos como configurar nuestros componentes para activar la comunicación vía email. A continuación los pasos a seguir para ejecutar esta configuración:&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Programación del micro vía Arduino IDE&lt;/li&gt;
&lt;li&gt;Creación del script que enviará los comandos a través del puerto serial&lt;/li&gt;
&lt;li&gt;Configuración de Mail-Alert el cual enlaza una regla con el script que creamos ateriormente&lt;/li&gt;
&lt;/ol&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSe6qzAY5dHk5c1gdeKmGLLZrrZOuUjzh8Hkaso-Wu_40Ie3aZnab1WBWrmAnG0nFftNeSaQFBqawGevkJN3Jm-mVSvLcQbs5402WI7H6lCBB2luPq6iBmsWHy_Q-E8VNyCqI1nz82goI/s1600/flow.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;267&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSe6qzAY5dHk5c1gdeKmGLLZrrZOuUjzh8Hkaso-Wu_40Ie3aZnab1WBWrmAnG0nFftNeSaQFBqawGevkJN3Jm-mVSvLcQbs5402WI7H6lCBB2luPq6iBmsWHy_Q-E8VNyCqI1nz82goI/s320/flow.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;El diagrama de flujo mostrado indica como un mensaje entrante es filtrado por thunderbird. En el caso que el subject del mensaje haga match con las condiciones indicadas en el filtro, este activará una regla definida en el add-on Mail-Alert la cual ejecutará el script que hace la interfaz con el puerto serial y hacia el micro. Este script también es capaz de responder al remitente del correo original con las acciones tomadas.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: orange;&quot;&gt;(1) Programación del micro&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Al igual que el artículo anterior estaremos utilizando una configuración de 4 leds conectados al micro. El firmware (programa) que utilizaremos es el mismo que en el artículo anterior el cual puede ser bajado &lt;a href=&quot;http://dl.dropbox.com/u/14647667/Blogs/CommunicacionSertial-Parte3/serialLed.pde&quot;&gt;aquí&lt;/a&gt;.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: orange;&quot;&gt;(2) Script de interacción con Arduino en python&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Hasta ahora hemos programados nuestros scripts con ksh, el cual puede ejecutarse desde cualquier linux. Para aumentar la portabilidad hemos creado para este ejemplo un script en python el cual es multiplataforma.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Este script recibe como parámetros el contenido del subject del correo entrante, el remitente de dicho correo y el puerto serial con el cual se estará interactuando.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Este script también tiene interacción con algún cliente de correo que tengan instalado en sus PCs. En mi caso utilizo ssmtp por su simplicidad y efectividad. Como yo utilizo Ubuntu como sistema operativo, ssmtp hace el trabajo muy bien y les indico un link en donde se puede obtener información de como instalarlo.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;http://tombuntu.com/index.php/2008/10/21/sending-email-from-your-system-with-ssmtp/&quot;&gt;Instalación y uso de ssmtp en ubuntu&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Nuestro script hace uso de ssmtp haciendo una llamada al sistema operativo utilizando la libreria subprocess, la cual permite hacer un fork de una llamada al sistema operativo para ejecutar un comando, y además podemos hacerle llegar los parámetros indicados. El siguiente extracto muestra la rutina para enviar el correo de vuelta al remitente.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;def send_email(mensaje):&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;&amp;nbsp; &amp;nbsp; try:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ssmtp = subprocess.Popen((&#39;/usr/sbin/ssmtp&#39;, destinatario), stdin=subprocess.PIPE)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;&amp;nbsp; &amp;nbsp; except OSError:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &#39;No se puedo iniciar sSMTP, por lo que el email no fue enviado&#39;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;&amp;nbsp; &amp;nbsp; #pasamos el contenido del mail a traves del stdin&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;&amp;nbsp; &amp;nbsp; ssmtp.communicate(cuerpo % (destinatario, remitente, mensaje))&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;&amp;nbsp; &amp;nbsp; # Esperamos a que termine de enviar el correo&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;&amp;nbsp; &amp;nbsp; ssmtp.wait()&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: orange;&quot;&gt;Download:&lt;/span&gt;&lt;/b&gt; &lt;a href=&quot;http://dl.dropbox.com/u/14647667/Blogs/CommunicacionSertial-Parte3/led-1.py&quot;&gt;SCRIPT&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;b&gt;(3) Configuración de Mail-Alert&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Este paso es el que permite que todo funcione. Cuando llega un correo thunderbird a través de sus filtros permite redireccionar el mismo a una regla que definimos para Mail-Alert, el cual ejecutará el script que interactua con el Arduino.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;(3.1) Creamos una regla en Mailbox-Alert&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;(3.2) Creamos un Filtro que direccione a la regla de Mailbox-Alert&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Una vez configuradas todas las partes involucradas en el proceso podemos probar enviando un email a yadirganbot@gmail.com con las siguientes características.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;El mensaje debe contener las instrucciones en el subject&lt;/li&gt;
&lt;li&gt;El subject debe empezar con @;-&amp;gt;&lt;/li&gt;
&lt;li&gt;Se puede indicar más de un comando en el subject&lt;/li&gt;
&lt;li&gt;Los comandos permitidos son:&lt;/li&gt;
&lt;ul&gt;&lt;li&gt;ledon, ledoff (Enciende o apaga todos los leds)&lt;/li&gt;
&lt;li&gt;ledNon, ledNoff: (1&amp;lt;N&amp;lt;4) (Enciende un led a la vez)&lt;/li&gt;
&lt;li&gt;titilar (Ejecuta intermitencia de todos los leds)&lt;/li&gt;
&lt;li&gt;secuencia1 (Ejecuta un led chaser de izquierda a derecha)&lt;/li&gt;
&lt;li&gt;secuencia2 (Ejecuta un led chaser de derecha a izquierda)&lt;/li&gt;
&lt;li&gt;pN, N&amp;gt;0 entero o decimal (indica una pausa en milisegundos)&lt;/li&gt;
&lt;li&gt;xN, N&amp;gt;=1 (permite repetir un comando)&lt;/li&gt;
&lt;/ul&gt;&lt;/ul&gt;&lt;div&gt;En este ejemplo vemos como enviamos una secuencia de comandos en el subject de un email cuyo destinatario es yadirganbot@gmail.com.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;To: yadirganbot@gmail.com&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;Subject: @;-&amp;gt; x3 secuencia1 p.5 x3 secuencia2 p.5 titilar p.5 ledon p2 ledoff&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Thunderbird a través del filtro creado detecta que la secuencia @;-&amp;gt; se encuentra en el subject del correo y lo envía a la regla creada en Mailbox-Alert. Por su parte Mailbox-Alert en su regla sabe que tiene que mostrar un pop-up indicando el remitente y el mensaje, además ejecutar el siguiente comando:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;/home/ydirgan/SCRIPTS/mailboxAlert/led-1.py &amp;nbsp;%subject %sender /dev/ttyACM0&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
en el cual se le pasan como parámetros (%subject) el título del correo, el cual contiene los comandos. El remitente (%sender), y finalmente el puerto serial por donde el micro está conectado al PC.&lt;br /&gt;
&lt;br /&gt;
El script led-1.py se ejecuta enviándole los comandos vía serial al micro, dejando huella en led-1.log y devolviendo el correo vía ssmtp al remitente.&lt;br /&gt;
&lt;br /&gt;
En el video que verán a continuación se puede observar el ciclo de comunicación con el micro.&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;b&gt;VIDEO:&lt;/b&gt;&lt;/span&gt; &lt;a href=&quot;http://youtu.be/-PRVyOfcsAU&quot;&gt;Comunicación por email con Arduino&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adirgan.blogspot.com/feeds/6787098793437202092/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://adirgan.blogspot.com/2012/01/comunicacion-con-el-arduino-via-correo.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/6787098793437202092'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/6787098793437202092'/><link rel='alternate' type='text/html' href='http://adirgan.blogspot.com/2012/01/comunicacion-con-el-arduino-via-correo.html' title='Comunicación vía email con Arduino'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/15931139500048857110</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSe6qzAY5dHk5c1gdeKmGLLZrrZOuUjzh8Hkaso-Wu_40Ie3aZnab1WBWrmAnG0nFftNeSaQFBqawGevkJN3Jm-mVSvLcQbs5402WI7H6lCBB2luPq6iBmsWHy_Q-E8VNyCqI1nz82goI/s72-c/flow.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192187322732553132.post-4440692986606409853</id><published>2012-01-15T17:54:00.000-08:00</published><updated>2012-01-29T08:48:09.177-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="chat"/><category scheme="http://www.blogger.com/atom/ns#" term="communication"/><category scheme="http://www.blogger.com/atom/ns#" term="email"/><category scheme="http://www.blogger.com/atom/ns#" term="pachube"/><category scheme="http://www.blogger.com/atom/ns#" term="serial"/><category scheme="http://www.blogger.com/atom/ns#" term="twitter"/><title type='text'>Comunicación con Arduino usando un cliente de mensajería</title><content type='html'>&lt;span style=&quot;color: orange; font-size: large;&quot;&gt;&lt;b&gt;Abstract&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
(&lt;a href=&quot;http://adirgan.blogspot.com/2012/01/communication-with-arduino-using-chat.html&quot;&gt;go to English Version&lt;/a&gt;)&lt;br /&gt;
&lt;br /&gt;
En el artículo anterior vimos la teoría básica de como comunicarnos con el microcontrolador a través del puerto serial de nuestro PC. ref: &lt;a href=&quot;http://adirgan.blogspot.com/2012/01/comunicacion-con-microcontroladores.html&quot;&gt;Comunicación con microcontroladores tipo Arduino&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
En este artículo veremos lo básico para hacer que el micro responda a órdenes enviadas a través de un cliente de mensajería, correo electrónico, pachube o twitter.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;Downloads:&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&lt;a href=&quot;http://dl.dropbox.com/u/14647667/Blogs/ComunicacionSerial-Parte2/serialLed.pde&quot; style=&quot;text-align: left;&quot;&gt;serialLed.pde&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;http://dl.dropbox.com/u/14647667/Blogs/ComunicacionSerial-Parte2/led1log.py&quot; style=&quot;text-align: left;&quot;&gt;led1log.py&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;http://dl.dropbox.com/u/14647667/Blogs/ComunicacionSerial-Parte2/led-1.ksh&quot; style=&quot;text-align: left;&quot;&gt;led-1.ksh&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;http://dl.dropbox.com/u/14647667/Blogs/ComunicacionSerial-Parte2/external&quot; style=&quot;text-align: left;&quot;&gt;external&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;color: #eeeeee;&quot;&gt;&lt;b&gt;VIDEO:&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;a href=&quot;http://www.youtube.com/watch?v=wLiQauM_A4E&quot;&gt;Paso a Paso&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;Sesión Interactiva:&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
Agregar contacto vía messenger (msn) ydirganbot@hotmail.com y Verificar el broadcast del circuito montado para ver los leds &lt;a href=&quot;http://www.livestream.com/microcontroladores&quot;&gt;AQUI&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: orange; font-size: large;&quot;&gt;&lt;b&gt;Intrucción&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Ya hemos visto como enviar o recibir información hacia y desde el micro utilizando el puerto serial. El paso a seguir es utilizar el micro para hacerlo reaccionar a órdenes enviadas a través de nuestro PC o analizar y reaccionar a información recibida del micro.&lt;br /&gt;
&lt;br /&gt;
En una primera instancia estudiaremos la forma de hacer reaccionar al micro de acuerdo a las órdenes que le podamos enviar por el puerto serial. Inicialmente hicimos enviar directamente las órdenes a través del puerto utilizando la modalidad directa, pero la idea de fondo es poder utilizar alguna interfaz que nos haga el trabajo más sencillo.&lt;br /&gt;
&lt;br /&gt;
Por ejemplo, trabajar con algún tipo de interfaz de comunicación, como un cliente de chat, correo electrónico, pachube o twitter, por nombrar los cuatro que vamos a explorar en este y los próximos 3 artículos.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: orange; font-size: large;&quot;&gt;Comunicación con el micro a través de messenger&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Buscando extensamente en la Web por software gratuito para utilizar algún cliente de chat me encontré con centerIM. Esta aplicación es un cliente muy ligero de chat, el cual puede configurarse con una variedad de cuentas públicas como messenger, yahoo, etc.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: orange;&quot;&gt;REF1:&lt;/span&gt;&lt;/b&gt; &lt;a href=&quot;http://www.centerim.org/&quot;&gt;CenterIM home&lt;/a&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: orange;&quot;&gt;REF2:&lt;/span&gt;&lt;/b&gt; &lt;a href=&quot;http://www.webupd8.org/2009/06/lightweight-im-client-centerim-runs-in.html&quot;&gt;centerIM Installation&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
En la referencia anterior puede accederse la página del producto así como un muy buen artículo de como instalarlo en ubuntu.&lt;br /&gt;
&lt;br /&gt;
La documentación que encuentran en la referencia 1 es muy amplia y con ella pueden configurar inicialmente el paquete. En mi caso yo lo configure con una cuenta que cree especialmente para este experimento.&lt;br /&gt;
&lt;br /&gt;
Siendo un cliente de chat funciona como cualquier otro cliente de&amp;nbsp;mensajería, pero con un adicional que encaja muy bien para nuestro objetivo. El centerIM permite programar scripts para ejecutar tareas de acuerdo al contenido de los mensajes entrantes. Con esta capacidad se pueden programar diferentes comportamientos de forma de enviar vía serial comandos al microcontrolador. Esto permite comunicarnos desde el messenger con el computador de la casa para por ejemplo ejecutar alguna tarea de activación de alarma, encender luces o apagarlas, etc.&lt;br /&gt;
&lt;br /&gt;
Esta configuración se debe hacer a través de un script que debe copiarse en &lt;i&gt;&lt;span style=&quot;color: magenta;&quot;&gt;$HOME/.centerim&lt;/span&gt;&lt;/i&gt; y cuyo nombre debe ser &lt;i&gt;&lt;span style=&quot;color: magenta;&quot;&gt;external&lt;/span&gt;&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
El formato del script external es muy simple.&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;%action &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Acción a tomar de acuerdo a las siguientes condiciones&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;event &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; msg&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;# Reacciona solo a mensajes&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;proto &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; msn&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;# Solamente &amp;nbsp;para el protocolo messenger&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;status &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;online&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;# responde solo si el status de la cuenta es online&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;options &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; stdin stdout&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;# .. los comandos externos (abajo) leen de&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;# stdin, luego su salida stdout es enviada como una respuesta&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;# a un usuario remoto&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;%exec&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;msg=`cat`&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;echo $(/home/ydirgan/.centerim/commTest.ksh &quot;$msg&quot;)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
%exec redirecciona el mensaje a un simple script que solo devuelve el mensaje por la misma vía.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;#commTest.ksh&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;#!/usr/bin/ksh&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;msg=`echo $1 | tr a-z A-Z`;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;printf &quot;arduino-1 orden rebibida: $msg&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Al momento de recibir el mensaje, centerIM redirecciona la salida al script commTest.ksh, este recibe el mismo como un parámetro el cual lo convertimos en mayúsculas y lo devolvemos a centerIM por el stdout.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;A partir de este simple ejemplo podemos modelar un pequeño script para encender/apagar 4 leds conectados a los pines digitales 0..3 de nuestro teensy.&lt;br /&gt;
&lt;br /&gt;
A continuación los pasos que deberemos seguir:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Crear un script ara el micro que responda a las órdenes enviadas vía serial&lt;/li&gt;
&lt;li&gt;Crear un script de logging del puerto serial&lt;/li&gt;
&lt;li&gt;Crear el script que es llamado desde &quot;external&quot;, el cual contiene la lógica de ejecución&lt;/li&gt;
&lt;li&gt;Crear el script &quot;external&quot; para centerIM&lt;/li&gt;
&lt;/ol&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;(1) Script para el Microcontrolador&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Este script responde a los comandos recibidos por el puerto serial del teensy (micro como el arduino).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;El script enciende o apaga un led en el pin n (1&amp;lt;=n&amp;lt;=4). Espera por un caracter que esté disponible en el puerto serial.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;entrada serial = 1: enciende el led 1&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;entrada serial = 2: apaga el led 1&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div&gt;entrada serial = 3: enciende el led 2&lt;/div&gt;&lt;div&gt;entrada serial = 4: apaga el led 2&lt;/div&gt;&lt;div&gt;entrada serial = 5: enciende el led 3&lt;/div&gt;&lt;div&gt;entrada serial = 6: apaga el led 3&lt;/div&gt;&lt;div&gt;entrada serial = 7: enciende el led 4&lt;/div&gt;&lt;div&gt;entrada serial = 8: apaga el led 4&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Una vez que descarguemos el programa debemos cargarlo en el micro. Una vez cargado podemos probar su comportamiento interactuando directamente conb el puerto, como se puede apreciar en el video al final del artículo.&lt;/div&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;b&gt;&lt;br class=&quot;Apple-interchange-newline&quot; /&gt;Download:&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;a href=&quot;http://dl.dropbox.com/u/14647667/Blogs/ComunicacionSerial-Parte2/serialLed.pde&quot;&gt;serialLed.pde&lt;/a&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;(2) Script de logging&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Este script tiene como objetivo copiar cada línea de salida de /dev/ttyACM0 a un archivo.log y&amp;nbsp;deberemos ejecutarlo en background para que se mantenga recopilando la salida del puerto.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;ydirgan@pragma-systems:~/SCRIPTS/centerIM$ led1log.py /dev/ttyACM0 &amp;amp;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: orange;&quot;&gt;Download:&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&lt;a href=&quot;http://dl.dropbox.com/u/14647667/Blogs/ComunicacionSerial-Parte2/led1log.py&quot;&gt;led1log.py&lt;/a&gt;&lt;br /&gt;
&lt;div&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;(3) Script con la lógica de ejecución&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
El tercer script permite ejecutar las secuencias de los comandos que requerimos enviarle al micro. Con las reducidas instrucciones que definimos en el micro podemos desde este script aumentar las funcionalidades.&lt;br /&gt;
&lt;br /&gt;
En este programa podemos encender o apagar leds individuales, pero también podemos encenderlos todos, apagarlos todos, hacer que titilen o que ejecuten una secuencia. Todo esto utilizando las primitivas que hemos programado en el micro.&lt;br /&gt;
&lt;br /&gt;
Además de las instrucciones propias de ejecución, se ha programado una ayuda que puede obtenerse al tipear HELP desde la ventana de chat, y su resultado será:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;arduino-1: este es una maquina de estado finita que permite interactuar con un microcontrolador tipo Arduino. Su uso esta destinado solo como ejemplo. El microcontrolador repondera cuando reconozca la orden a ejecutar. Se tienen 4 led, para encender y apagar cada uno de ellos. Los comandos que puedes utilizar son: ledNon, en donde n es el numero del led (1&amp;lt;=N&amp;lt;=4). ledNoff, en donde n es el numero del led (1&amp;lt;=N&amp;lt;=4). ledon, todos los leds se encenderan. ledoff, todos los led se apagaran. tilitar, todos los led titilaran 20 veces. secuencia1, todos los led encienden en secuencia (tipo led chaser) de izquierda a derecha. secuencia2, todos los led encienden en secuencia (tipo led chaser) de derecha a izquierda. help, muestra esta ayuda.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: orange;&quot;&gt;Download:&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&lt;a href=&quot;http://dl.dropbox.com/u/14647667/Blogs/ComunicacionSerial-Parte2/led-1.ksh&quot;&gt;led-1.ksh&lt;/a&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;(4) Script external para centerIM&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
Por último el script que ejecuta centerIM cuando le enviamos un mensaje. Este será el que dispare la ejecución del script led-1.ksh, que enviará nuestros comandos vía serial. El micro los procesará y responderá de acuerdo a la secuencia de comandos.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: orange;&quot;&gt;Download:&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&lt;a href=&quot;http://dl.dropbox.com/u/14647667/Blogs/ComunicacionSerial-Parte2/external&quot;&gt;external&lt;/a&gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Finalmente ejecutamos centerim desde nuestro terminal para activar el robot.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;El video para mostrar la secuencia de pasos es el siguiente:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;color: orange;&quot;&gt;VIDEO: &lt;/span&gt;&lt;/b&gt;&lt;a href=&quot;http://www.youtube.com/watch?v=wLiQauM_A4E&quot;&gt;Paso a Paso&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Para probarlo solo habría que agregar a ydirganbot@hotmail.com al messenger. Este responderá cuando esté online.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adirgan.blogspot.com/feeds/4440692986606409853/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://adirgan.blogspot.com/2012/01/comunicacion-con-microcontroladores_15.html#comment-form' title='3 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/4440692986606409853'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/4440692986606409853'/><link rel='alternate' type='text/html' href='http://adirgan.blogspot.com/2012/01/comunicacion-con-microcontroladores_15.html' title='Comunicación con Arduino usando un cliente de mensajería'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/15931139500048857110</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192187322732553132.post-6412417046662723624</id><published>2012-01-11T07:53:00.000-08:00</published><updated>2012-01-29T08:09:20.294-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="communication"/><category scheme="http://www.blogger.com/atom/ns#" term="interaction"/><title type='text'>Comunicación Serial con Arduino</title><content type='html'>&lt;span style=&quot;color: orange; font-size: large;&quot;&gt;&lt;b&gt;Abstract&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
(&lt;a href=&quot;http://adirgan.blogspot.com/2012/01/serial-communication-with-arduino.html&quot;&gt;go to English Version&lt;/a&gt;)&lt;br /&gt;
&lt;br /&gt;
Una de las principales ventajas de un micro es la posibilidad que tenemos de comunicarnos con el mismo vía puerto serial.&lt;br /&gt;
&lt;br /&gt;
En este artículo y próximos tendremos un acercamiento a lo que podemos hacer, y algunas de las herramientas que he encontrado interesantes para interactuar con un microcontrolador, involucrando internet...&lt;br /&gt;
&lt;br /&gt;
A menos que un micro se programe con una implementación standalone, es decir, que se su funcionamiento se circunscriba a acciones que no dependan de la interacción externa (más allá de sus entradas digitales o analógicas), no será necesario ejecutar los mecanismos que en este artículo se describen. Es cierto que muchas de las aplicaciones de los microcontroladores no requieren asomarse a su entorno, pero cada vez es más común pensar en la comunicación como herramienta de interacción con las aplicaciones que diseñamos para estos ambientes. Para muestra, veamos el siguiente ejemplo.&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: orange; font-size: large;&quot;&gt;...&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: orange; font-size: large;&quot;&gt;Comunicación con microControladores tipo Arduino&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Si poseemos una casa con ventanas panorámicas (de estas que se abren deslizándolas horizontalmente), tal que una persona puede entrar sin inconvenientes a través del espacio disponible una vez abiertas, y nos gusta salir a menudo de vacaciones, tendremos un problema de seguridad. La probabilidad que irrumpan en nuestro hogar en esos momentos en que la casa está sola será muy alta. &lt;br /&gt;
&lt;br /&gt;
Para alguien que quiera diseñar su sistema de seguridad, en primera instancia seguramente pensará en colocar sensores de movimiento o apertura para activar una alarma muy ruidosa al momento que haya una intrusión en la residencia. Esto puede ser una solución, pero la alarma alertará solo al entorno inmediato a la casa, y a los intrusos.&lt;br /&gt;
&lt;br /&gt;
Ahora bien, también podemos pensar en un sistema de seguridad silencioso al entorno inmediato a la residencia, pero que a través de un sistema de comunicación al exterior vía internet, envíe un mensaje de texto con la alerta a algún medio de recepción, sea email, chat client (messenger) o a twitter!.&lt;br /&gt;
&lt;br /&gt;
Otro ejemplo de comunicación remota es, por ejemplo, la posibilidad de crear un sistema de control de luces y electrodomésticos en nuestro hogar. El mismo puede ser automatizado desde el micro definiendo un horario de ejecución de eventos para encender o apagar luces, mover una celda solar orientándola al sol de forma eficiente, motorizar una ventana para la entrada de luz de acuerdo a la luminosidad del entorno o simplemente encender el aire acondicionado de nuestra habitación cercano a la hora de nuestra llegada.&lt;br /&gt;
&lt;br /&gt;
Con este último ejemplo, que tal si llegamos más temprano a casa?. Pudiéramos comunicarnos con nuestro micro utilizando nuestro celular inteligente a través de messenger enviando un mensaje como el siguiente:&lt;br /&gt;
&lt;br /&gt;
AC: encender&lt;br /&gt;
&lt;br /&gt;
De esta forma y a través del software adecuado, este mensaje puede ser recibido y ejecutado, en línea.&lt;br /&gt;
&lt;br /&gt;
Como estos ejemplos, existen muchos más que solo la imaginación y la necesidad particular pueden producir.&lt;br /&gt;
&lt;br /&gt;
Para realizar tareas como estas, debemos empezar de lo sencillo a lo complejo. Lo primero que debemos saber es que con los microcontroladores como el arduino, pinguino, teensy, etc. podemos comunicarnos a un servidor vía puerto &lt;a href=&quot;http://en.wikipedia.org/wiki/Serial_communication&quot;&gt;serial&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Con &lt;a href=&quot;http://www.arduino.cc/&quot;&gt;arduino&lt;/a&gt; o &lt;a href=&quot;http://www.pjrc.com/teensy/&quot;&gt;teensy&lt;/a&gt; la comunicación serial se establece a través de la interfaz USB de la cual disponemos para conectar el micro al computador. Al inicializar el puerto serial desde el micro, en ambientes linux/unix se mapeará un directorio en /dev/ttyXXXn que permitirá enviar o recibir información.&lt;br /&gt;
&lt;br /&gt;
El siguiente código define la salida secuencial de un mensaje al puerto serie de nuestro computador.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;int i=0;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;void setup()&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;{&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;Serial.begin(9600);&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;}&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;void loop()&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;{&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;Serial.print(&quot;mensaje de prueba: &quot;);&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;Serial.println(++i);&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;delay(1000);&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;}&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
En el bloque setup() inicializamos el puerto serial a 9600 baudios con Serial.begin(9600). En el bloque loop() enviamos vía serial el mensaje seguido de un consecutivo el cual actualizamos secuencialmente con ++i. &lt;br /&gt;
&lt;br /&gt;
Desde el computador podremos observar esta salida si interrogamos adecuadamente al puerto mapeado en /dev/ttyACMn. Donde n&amp;gt;=0.&lt;br /&gt;
&lt;br /&gt;
Para este ejemplo el puerto fue mapeado contra /dev/ttyACM0. En mi caso utilizo ubuntu, pero para cualquier linux/MAC debe ser muy similar.&lt;br /&gt;
&lt;br /&gt;
Cuando el micro es conectado a cualquier puerto USB de nuestro computador el mismo puede ser accedido vía línea de comando desde un terminal o a través de algún programa hecho para este fin. Una tercera opción es crear nuestro propio programa de lectura y/o escritura al puerto serial. Esta última opción es la adecuada si quisiéramos interactuar con el puerto para obtener información del puerto o instruir al micro a ejecutar alguna acción.&lt;br /&gt;
&lt;br /&gt;
Para nuestro sencillo ejemplo podemos interrogar inicialmente al puerto utilizando el terminal serial que viene como herramienta del IDE de Arduino o a través de gtkterminal o minicom.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: orange;&quot;&gt;VIDEO:&amp;nbsp;&lt;a href=&quot;http://www.youtube.com/watch?v=BOLskuY025I&quot;&gt;Comunicación Serial 1&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Desde el micro podemos también leer desde el puerto serial y así poder tomar decisiones de que ejecutar de acuerdo a la entrada.&lt;br /&gt;
&lt;br /&gt;
El siguiente programa permite simplemente leer la entrada serial y devolver la cadena de caracteres obtenida, detectando el fin de línea.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;char caracter;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;byte i=0;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;char cadena[100];&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;void setup()&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;{&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;Serial.begin(9600);&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;}&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;void loop()&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;{&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;if (Serial.available())&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;{&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;caracter=Serial.read();&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;if (caracter == 10)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;{&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;cadena[i++]=&#39;\0&#39;;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;i=0;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;Serial.println(cadena);&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;}&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;else&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;cadena[i++]=caracter;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;}&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;}&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
En el bloque setup() inicializamos el puerto, seguidamente en el bloque loop() chequeamos el buffer del puerto con Serial.available().&lt;br /&gt;
&lt;br /&gt;
Si hay caracteres disponibles los leemos secuencialmente con Serial.read(). Si detectamos el fin de línea agregamos a la cadena de caracteres el caracter de fin de cadena y reseteamos el contador, enviando de vuelta la cadena de caracteres al puerto.&lt;br /&gt;
&lt;br /&gt;
En caso que no sea un fin de linea (10) entonces vamos anexando a la cadena cada catacter recibido actualizando el indice i.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: orange;&quot;&gt;VIDEO:&amp;nbsp;&lt;a href=&quot;http://www.youtube.com/watch?v=ncLGY8X3OHw&quot;&gt;Comunicación Serial 2&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Ahora veamos como utilizar este último programa para adecuarlo para accionar el encendido o el apagado el aire acondicionado del segundo ejemplo mostrado en este artículo.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;#include string.h&lt;/span&gt;&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;br /&gt;
#define ENCENDER 1&lt;br /&gt;
#define APAGAR 0&lt;br /&gt;
char caracter;&lt;br /&gt;
byte i=0;&lt;br /&gt;
char cadena[100];&lt;br /&gt;
&lt;br /&gt;
void AC_Action(int accion)&lt;br /&gt;
{&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;br /&gt;
&lt;string.h&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;if (accion == ENCENDER)&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;br /&gt;
&lt;string.h&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;{&lt;/span&gt;&lt;/string.h&gt;&lt;br /&gt;
&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;Serial.println(&quot;Encendiendo el Aire Acondicionado Principal... &quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #eeeeee;&quot;&gt;&lt;string.h&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;//Accion de encender&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #eeeeee;&quot;&gt;&lt;string.h&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;//esperar resultado&lt;/span&gt;&lt;br /&gt;
&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;delay(500);&lt;/span&gt;&lt;br /&gt;
&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;Serial.println(&quot;Aire Acondicionado Encendido...  Status OK&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;string.h&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;} &lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;br /&gt;
&lt;string.h&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;if (accion == APAGAR)&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;br /&gt;
&lt;string.h&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;Serial.println(&quot;Apagando el Aire Acondicionado Principal... &quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #eeeeee;&quot;&gt;&lt;string.h&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;//Accion de apagado&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #eeeeee;&quot;&gt;&lt;string.h&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;/&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;/esperar resultado&lt;/span&gt;&lt;br /&gt;
&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;delay(500);&lt;/span&gt;&lt;br /&gt;
&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;Serial.println(&quot;Aire Acondicionado Apagado...  Status OK&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;}&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt; }&lt;br /&gt;
void setup()&lt;br /&gt;
{&lt;/span&gt;&lt;/string.h&gt;&lt;br /&gt;
&lt;string.h&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;Serial.begin(9600);&lt;br /&gt;
}&lt;br /&gt;
void loop()&lt;br /&gt;
{&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;br /&gt;
&lt;string.h&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;if (Serial.available())&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;br /&gt;
&lt;string.h&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;caracter=Serial.read();&lt;/span&gt;&lt;br /&gt;
&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;if (caracter == 10)&lt;/span&gt;&lt;br /&gt;
&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;cadena[i++]=&#39;\0&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;i=0;&lt;/span&gt;&lt;br /&gt;
&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;if (!strcmp(cadena,&quot;AC: Encender&quot;))&lt;/span&gt;&lt;br /&gt;
&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;AC_Action(ENCENDER);&lt;/span&gt;&lt;br /&gt;
&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;if (!strcmp(cadena,&quot;AC: Apagar&quot;))&lt;/span&gt;&lt;br /&gt;
&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;AC_Action(APAGAR);&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;}&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;else&lt;/span&gt;&lt;br /&gt;
&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;cadena[i++]=caracter;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/string.h&gt;&lt;string.h style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/string.h&gt;&lt;span style=&quot;color: #eeeeee;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;string.h&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt; }&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Hemos creado una procedimiento que dependiendo del parámetro acción encenderá o apagará el aire acondicionado, asumiendo que tenemos un dispositivo conectado al micro capaz de hacerlo. En nuestro caso el micro devolverá vía serial el mensaje de encendido y apagado correspondiente.&lt;br /&gt;
&lt;br /&gt;
El bloque loop() mantiene el mismo esquema, solo que cuando se hace match con una cadena específica se ejecuta la función AC_Action() pasándole el parámetro ENCENDER o APAGAR definidos al principio del programa.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: orange;&quot;&gt;VIDEO:&amp;nbsp;&lt;a href=&quot;http://www.youtube.com/watch?v=-ahIsMCD-Ak&quot;&gt;Comunicación Serial 3&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
El próximo paso va a ser comunicarnos desde el exterior del PC a través de diferentes medios para poder interactuar con el micro.&lt;br /&gt;
&lt;br /&gt;
En próximos artículos seguiremos explorando posibilidades de comunicación, interacción y ejecución.&lt;/string.h&gt;</content><link rel='replies' type='application/atom+xml' href='http://adirgan.blogspot.com/feeds/6412417046662723624/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://adirgan.blogspot.com/2012/01/comunicacion-con-microcontroladores.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/6412417046662723624'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/6412417046662723624'/><link rel='alternate' type='text/html' href='http://adirgan.blogspot.com/2012/01/comunicacion-con-microcontroladores.html' title='Comunicación Serial con Arduino'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/15931139500048857110</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192187322732553132.post-4227102939386769702</id><published>2011-06-19T07:22:00.001-07:00</published><updated>2011-07-03T12:53:31.259-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="analog input"/><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="dirgan"/><category scheme="http://www.blogger.com/atom/ns#" term="Introduction"/><category scheme="http://www.blogger.com/atom/ns#" term="microcontroller"/><category scheme="http://www.blogger.com/atom/ns#" term="pic"/><category scheme="http://www.blogger.com/atom/ns#" term="pinguino"/><title type='text'>Entrada Analógica (Analog Input)</title><content type='html'>Hoy nos dedicaremos a interactuar con una entrada analógica, la cual a diferencia de una entrada digital (entrega anterior) permite leer un rango de valores. Estos valores representan voltaje, pero dentro del microcontrolador pueden ser representados por un rango de valores enteros, los cuales pueden ir de 0 a 255 o de 0 a 1024, etc., esto depende del tipo de procesador que estemos utilizando... por eso es muy útil obtener las especificaciones del micro y las funciones asociadas (en el lenguaje que escogiéramos) a la lectura de un puerto analógico.&lt;br /&gt;&lt;br /&gt;La idea de un puerto analógico es leer de un puerto diferentes valores, lo cual permite tomar decisiones más amplias o interactuar con rangos que permiten realizar tareas diferentes.&lt;br /&gt;&lt;br /&gt;En lo personal, cuando pienso en una entrada digital pienso en un switch on/off, y cuando pienso en una entrada analógica pienso en un potenciómetro, o cualquier dispositivo cuya salida oscile entre 0V y 5V.&lt;br /&gt;&lt;br /&gt;Estos dispositivos (ejemplo un lm35 - termómetro digital) alimentándolos con 5V, pueden entregar al puerto en donde se conecten un rango de valores de acuerdo a las características con las cuales el dispositivo está diseñado.&lt;br /&gt;&lt;br /&gt;Por ejemplo, un potenciómetro permite entregar al micro un rango de voltaje que depende del voltaje con el cual esté alimentado. Un termómetro digital, entregará un voltaje de acuerdo a la alimentación del mismo y a las condiciones de temperatura a la cual esté expuesto. En cualquier caso, siempre se obtiene un voltaje asociado a la lectura del dispositivo, y a través de este voltaje podemos tomar decisiones y ejecutar tareas.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;El siguiente circuito conecta 8 leds a la plataforma de prototipado pinguino en los pines 0-7, que son puertos digitales. Un potenciómetro es conectado a los puertos GND,VCC del micro y su salida la enviamos al puerto 13, el cual es analógico.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiesJQe7bmkzapZqeQtBDugVoDWVH2uYoq7T1c3kShWw9ldY9PO-Ijq6AXz-FQGL_TfGAz0egpI9E6vhfWbWaMJNWxJKrIYV8TxbhY192y5CwLTLfe1Raym5jPl_xKNoZ1Dw2bm_tlCR-A/s1600/Pantallazo.png&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiesJQe7bmkzapZqeQtBDugVoDWVH2uYoq7T1c3kShWw9ldY9PO-Ijq6AXz-FQGL_TfGAz0egpI9E6vhfWbWaMJNWxJKrIYV8TxbhY192y5CwLTLfe1Raym5jPl_xKNoZ1Dw2bm_tlCR-A/s400/Pantallazo.png&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5624179234175567714&quot; style=&quot;cursor: pointer; width: 400px; height: 351px; &quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;El código que utilizaremos permite utilizar los 8 leds como una barra de indicación. Cuando el potenciómetro está en el tope izquierdo, este entrega al puerto 13  cero voltios. Cuando el potenciómetro está en el tope derecho le entrega al puerto 5V.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;El micro traduce este voltaje en un número entero que oscilará entre 0 y 1024, dependiendo del voltaje, el cual estará en un rango de oV a 5V.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Nuestra intención es que a medida que vamos rotando el potenciómetro a la derecha (0-&amp;gt;5)V la barra de 8 leds debe ir iluminándose a la derecha hasta llegar a encender los 8 leds, justamente cuando el potenciómetro esté en el tope derecho. En la rotación contraria (5-&amp;gt;0)V, los leds deben irse apagando uno a uno de derecha a izquierda hasta quedar todos apagados.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;A continuación el codigo&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;// Ejemplo de utilización de lectura de potenciometro y encendido de leds&lt;/div&gt;&lt;div&gt;#include &quot;ADlib/__map.c&quot;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;const int potPin=13;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;void setup()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;   byte i;&lt;/div&gt;&lt;div&gt;   for (i=0; i &amp;lt; 8; i++)&lt;/div&gt;&lt;div&gt;      pinMode(i,OUTPUT);&lt;/div&gt;&lt;div&gt;   pinMode(potPin,INPUT);&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;void apagarLeds()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;   byte i;&lt;/div&gt;&lt;div&gt;   for (i=0; i&amp;lt;8; i++)&lt;/div&gt;&lt;div&gt;   digitalWrite(i,LOW);&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;void encenderLeds(int count)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;   byte i;&lt;/div&gt;&lt;div&gt;   for (i=0; i&lt;count; div=&quot;&quot;&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&amp;lt;count; i++)&lt;div&gt;      digitalWrite(i,HIGH);&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;void loop()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;   apagarLeds();&lt;/div&gt;&lt;div&gt;   encenderLeds(map(analogRead(potPin),0,1024,0,8));&lt;/div&gt;&lt;div&gt;   delay(50);&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Veamos como funciona esto. En primer lugar tenemos la declaración de una constante (potPin) que nos indica cual es el puerto que utilizaremos para leer el voltaje que nos entrega el potenciómetro.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Luego tenemos la función setup() para definir la modalidad de los puertos. Los puertos de entrada(0,7) los definimos como salidas en el ciclo for. Asimismo, el puerto 13 lo definimos como entrada con la función pinMode.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Hemos creado 2 funciones. apagarLeds() nos permite apagar todos los leds al tiempo utilizando un ciclo for con el siguiente rango (0&amp;lt;=i&amp;lt;8). Luego definimos una función que nos permite encender hasta el led definido por el parámetro count.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;En el ciclo Loop(), vemos como apagamos los leds para luego encender hasta el led que nos devuelve la función map.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;La función map es una función que nos permite convertir un rangoA en un rangoB. Esta función es estándar en arduino, pero no en pinguino, por lo que está programada y agregada al directorio de librerías de pinguino, y es por esta razón que la segunda línea existe.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;#include &lt;adlib c=&quot;&quot;&gt;&lt;/adlib&gt;&quot;ADlib/__map.c&quot;&lt;/div&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;En nuestro caso, la función mapea el rango (0,1024) al rango (0,8) utilizando como entrada lo que devuelve analogRead(potPin). Esta conversión es muy conveniente ya que directamente le pasamos un valor entre 0 y 8 a la función encenderLeds(). Este ciclo se repite infinitamente cada 50 milisegundos debido la función delay(50) que hemos colocado al final del loop.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;// map function&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;b&gt;// Alejandro-Dirgan 2011&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;#ifndef __MAP__&lt;/div&gt;&lt;div&gt;#define __MAP__&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;#define MAP 1&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;float map(int value, int fLow, int fHigh, int tLow, int tHigh)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;   return ((float )tHigh*(float )(value-fLow)+(float )tLow*(fHigh-value))/(float )(fHigh-fLow);&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;#endif&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Veamos como funciona en la práctica.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;http://www.youtube.com/watch?v=wR58huv79KI&quot;&gt;link de Video&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Con las entradas analógicas se pueden hacer infinidad de cosas, solo la imaginación y los requerimientos lo dirán.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;En la próxima entrega veremos las salidas analógicas.&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/count;&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adirgan.blogspot.com/feeds/4227102939386769702/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://adirgan.blogspot.com/2011/06/entrada-analogica-analogic-input.html#comment-form' title='1 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/4227102939386769702'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/4227102939386769702'/><link rel='alternate' type='text/html' href='http://adirgan.blogspot.com/2011/06/entrada-analogica-analogic-input.html' title='Entrada Analógica (Analog Input)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/15931139500048857110</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiesJQe7bmkzapZqeQtBDugVoDWVH2uYoq7T1c3kShWw9ldY9PO-Ijq6AXz-FQGL_TfGAz0egpI9E6vhfWbWaMJNWxJKrIYV8TxbhY192y5CwLTLfe1Raym5jPl_xKNoZ1Dw2bm_tlCR-A/s72-c/Pantallazo.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192187322732553132.post-7805792921127165165</id><published>2011-06-16T17:21:00.000-07:00</published><updated>2011-06-19T07:10:28.163-07:00</updated><title type='text'>Entrada Digital (Digital Input)</title><content type='html'>En el artículo anterior vimos como utilizar las salidas del microcontrolador para encender y apagar leds, utilizando valores lógicos altos y bajos (0,5V):(LOW;HIGH) con la función digitalWrite(). En este artículo utilizaremos los puertos para obtener información del entorno. &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Generalmente cuando pensamos en una entrada digital, inmediatamente evocamos un switch ON/OFF. Cuando el swith está en off, no hay paso de energía y nuestro puerto, al cual está conectado el switch, se encontrará en un nivel bajo (LOW, 0v). Por el contrario, si el switch está en ON, el mismo permitirá el paso de energía y el puerto destino obtendrá un valor alto (HIGH, 5v). Esta lógica esta perfecta, pero veamos como podemos implementarla adecuadamente y veremos las variantes correspondientes.&lt;br /&gt;&lt;br /&gt;Lo primero que debemos entender es como mantenemos un valor estable en un puerto de entrada. Como estamos hablando de una entrada digital, nuestra intención es determinar cuando la misma tiene un valor alto o bajo, y luego tomar una decisión al respecto, para por ejemplo encender un led, iniciar una secuencia de comandos, para activar un parámetro, etc.&lt;br /&gt;&lt;br /&gt;En general, si no definimos una voltaje en una entrada digital esta podrá tener un valor flotante, lo cual debemos evitar. Requerimos tener un valor alto o un valor bajo, y esto se logra a través de las resistencias pull-up o pull-down.&lt;br /&gt;&lt;br /&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1VvOi-GNHtIDpP1SF3KFrFnDuedZQ-ewUaEu9fR1dIlft5nO0a19eVTOpAwmeiOFishpyJOCc5S3Rc5UqKkVx4enhHehE5X-XEx9ASAUCaDaYB0O5DY8QmMDIYzH5vJBO3m6CA94rklg/s1600/pull-up1.JPG&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1VvOi-GNHtIDpP1SF3KFrFnDuedZQ-ewUaEu9fR1dIlft5nO0a19eVTOpAwmeiOFishpyJOCc5S3Rc5UqKkVx4enhHehE5X-XEx9ASAUCaDaYB0O5DY8QmMDIYzH5vJBO3m6CA94rklg/s400/pull-up1.JPG&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5618983574566735154&quot; style=&quot;float: right; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 10px; cursor: pointer; width: 232px; height: 325px; &quot; /&gt;&lt;/a&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/span&gt;En la figura de la derecha vemos como el terminal 1 del circuito lógico puede ser alimentado con un valor bajo (LOW, 0V) en el momento que el switch S1 es presionado.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Esto efectivamente sucede cuando el switch S1 se presiona, ya que hay un camino directo desde tierra a este terminal. Pero que pasa cuando S1 esta abierto?. El problema es que no podemos garantizar que valor lee el terminal 1 cuando esta condición prevalece.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;En toda entrada lógica digital siempre debemos garantizar los dos valores a leer (alto y bajo), de forma que no haya ambigüedad.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Para ello existen dos modalidades, utilizando conceptos básicos de circuitos digitales: las resistencias pull-up y pull-down.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Veamos la siguiente figura:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpbWGnkKuvzz-FNHeMjicpCpVWY1_78Tx0oKZ6lB5mh_kNFEWi7lMHD67sqsJwy2ghkY1lkrU60NCd_CL7gnu-dlUnUi6q7wXV1pfh-vAaDMq6KM8vN6l8CLs_xrCHm7cmbRA-0fk1wTw/s1600/pull-up2.JPG&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpbWGnkKuvzz-FNHeMjicpCpVWY1_78Tx0oKZ6lB5mh_kNFEWi7lMHD67sqsJwy2ghkY1lkrU60NCd_CL7gnu-dlUnUi6q7wXV1pfh-vAaDMq6KM8vN6l8CLs_xrCHm7cmbRA-0fk1wTw/s400/pull-up2.JPG&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5618987453800914594&quot; style=&quot;cursor: pointer; width: 400px; height: 257px; &quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;En el circuito de la izquierda podemos observar que el terminal 1 esta conectado a través de una resistencia pull-up a Vcc (HIGH, 5V), cuando S1 está abierto. En este estado estamos garantizando un valor Alto cuando S1 no está presionado. Cuando S1 se presiona, el terminal 1 quedará conectado directamente a tierra, obteniendo un valor bajo (LOW, 0V). El valor de la resistencia puede conseguirse persiguiendo un valor bajo de corriente a circular entre VCC y Masa, utilizando V=I*R. La idea es dejar pasar menos de 1 mA para no dañar ni el circuito ni el cableado (en general el valor de esta resistencia está entre 10K y 47K).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;En el circuito de la derecha estamos implementando una resistencia pull-Down a Tierra (LOW, 0V), garantizando 0V cuando S1 está abierto y 5V cuando S1 esta cerrado. De esta forma estamos garantizando en cualquier caso un valor predicho que podemos leer desde nuestro microcontrolador.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Como podemos observar, dependiendo que variante hayamos escogido, S1 puede representar un valor alto o bajo cuando está presionado, y viceversa. Depende de nuestra lógica y de como deseemos programar nuestro la escogencia de alguna de las modalidades descritas anteriormente.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;OK. ya sabemos entonces como colocar un valor predecible en una entrada, ahora veamos como leerla y utilizarla para nuestros fines.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;La figura muestra la conexión hecha para que el sketch que mostramos funcione adecuadamente.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgulQlL6n72mFMkeur0GUAbypgPlTZxboFUlNOLF9vMN2I7sC5LC96Kx5DTbvm1Ct3aWYEq_s25-kXMlhIi9r9DBNd6LgjrgJhGh2LgYzbB-gEdtcSOPFJVZHt9yvLwfgqlVP7rZNVnYDY/s1600/digitalinput.png&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgulQlL6n72mFMkeur0GUAbypgPlTZxboFUlNOLF9vMN2I7sC5LC96Kx5DTbvm1Ct3aWYEq_s25-kXMlhIi9r9DBNd6LgjrgJhGh2LgYzbB-gEdtcSOPFJVZHt9yvLwfgqlVP7rZNVnYDY/s400/digitalinput.png&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5619932925912902562&quot; style=&quot;cursor: pointer; width: 400px; height: 141px; &quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;El siguiente programa muestra &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;const int potPin=14, ledPin=12;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;void setup()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;   pinMode(potPin,INPUT);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;   pinMode(ledPin,OUTPUT); &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;void loop()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;  if (analogRead(potPin))&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;   digitalWrite(ledPin,LOW);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;  else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;   digitalWrite(ledPin,HIGH);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;  delay(50);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Objetivo:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Demostrar como leer una entrada digital y tomar una decisión de acuerdo a lo leído, para la ejecución de una acción.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Descripción:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;b&gt;(1) const int potPin=14, ledPin=12;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Definen constantes asociadas a el pin de entrada (14) y el pin de salida (12).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;i&gt;(2) Procedimiento setup()&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;div&gt;&lt;i&gt;{&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;   pinMode(potPin,INPUT);&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;   pinMode(ledPin,OUTPUT);&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;}&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Definimos los pines como de entrada y salida en el procedimiento de setup.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;i&gt;(3) procedimiento loop()&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;{&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;div&gt;&lt;i&gt;  if (analogRead(potPin))&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;    digitalWrite(ledPin,LOW);&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;  else&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;    digitalWrite(ledPin,HIGH);&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;  delay(50);&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;}&lt;/i&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;En el loop del programa, vemos una estructura de toma de decisiones.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;i&gt;if (analogRead(potPin))&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;analogRead es una función que permite obtener una lectura del pin potPin (14). En la estructura &lt;b&gt;&lt;i&gt;if&lt;/i&gt;&lt;/b&gt;  lo único que requerimos es saber si esta lectura es mayor que cero (0), para apagar el led, o si la lectura es cero (0) (cuando se evalúa el else), para en encender el led.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Esta lógica aplica porque el circuito que montamos está basado en una resistencia pull-up.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Este ciclo se repite cada 50 milisegundos. Si el switch está abierto el &lt;i&gt;if (analogRead(potPin))&lt;/i&gt; nos retornará &lt;i&gt;true&lt;/i&gt;, y apagaremos el led con  &lt;i&gt;digitalWrite(ledPin,LOW).&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;Por el contrario, si el switch está cerrado el potPin estará conectado directamente a tierra y se leerá un valor bajo (oV), lo que hace que en el ciclo del programa la instrucción asociada al &lt;b&gt;&lt;i&gt;else&lt;/i&gt;&lt;/b&gt; se ejecute: &lt;i&gt;digitalWrite(ledPin,HIGH).&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;Es muy sencilla su programación. Luego compilamos el programa buscando que todo esté OK y reprogramamos el microcontrolador (en mi caso el pinguino) y dejamos que ejecute el programa.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;En el &lt;a href=&quot;http://www.youtube.com/watch?v=M4osS-mAY0k&quot;&gt;video&lt;/a&gt; se puede observar que he agregado un display lcd 16x2 para mostrar si el valor de potPin es alto o bajo y para indicar que estamos ejecutando de acuerdo a estos valores.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;</content><link rel='replies' type='application/atom+xml' href='http://adirgan.blogspot.com/feeds/7805792921127165165/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://adirgan.blogspot.com/2011/06/entrada-digital-digital-input.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/7805792921127165165'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/7805792921127165165'/><link rel='alternate' type='text/html' href='http://adirgan.blogspot.com/2011/06/entrada-digital-digital-input.html' title='Entrada Digital (Digital Input)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/15931139500048857110</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1VvOi-GNHtIDpP1SF3KFrFnDuedZQ-ewUaEu9fR1dIlft5nO0a19eVTOpAwmeiOFishpyJOCc5S3Rc5UqKkVx4enhHehE5X-XEx9ASAUCaDaYB0O5DY8QmMDIYzH5vJBO3m6CA94rklg/s72-c/pull-up1.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192187322732553132.post-2523679158068133282</id><published>2011-06-06T10:32:00.000-07:00</published><updated>2011-06-07T05:50:43.146-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="design"/><category scheme="http://www.blogger.com/atom/ns#" term="digital output"/><category scheme="http://www.blogger.com/atom/ns#" term="dirgan"/><category scheme="http://www.blogger.com/atom/ns#" term="interactivity"/><category scheme="http://www.blogger.com/atom/ns#" term="leds"/><category scheme="http://www.blogger.com/atom/ns#" term="microcontroller"/><category scheme="http://www.blogger.com/atom/ns#" term="output}"/><category scheme="http://www.blogger.com/atom/ns#" term="pic"/><title type='text'>Playing with LEDS</title><content type='html'>En la entrega anterior vimos como utilizar las salidas digitales. En este artículo solo quiero mostrar que lo que se puede hacer con las salidas digitales es directamente proporcional a lo que podemos hacer programando.&lt;br /&gt;&lt;br /&gt;La inteligencia de estos dispositivos electrónicos es solo cuestión de imaginación y capacidad de programación.&lt;br /&gt;&lt;br /&gt;En esta entrega quiero mostrarles como hacer un divertimento de iluminación de leds.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;EL ESQUEMA&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;7 LEDs conectados a las salidas 0-6 del pinguino 2550.&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoaGL5VltpXJ99oWsgRkGeVsUQQlsUGpRV9hzi6Wtc5Zxa_6Od0SRcSbgqauOjOXH1PL7oOqTwaRxx6aR9rkBw4KLjKj-1a8Onm7nDa3gQeGxwUkvO3a94cbXk_GvyDXHLkov58VmldLY/s1600/leds.jpg&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoaGL5VltpXJ99oWsgRkGeVsUQQlsUGpRV9hzi6Wtc5Zxa_6Od0SRcSbgqauOjOXH1PL7oOqTwaRxx6aR9rkBw4KLjKj-1a8Onm7nDa3gQeGxwUkvO3a94cbXk_GvyDXHLkov58VmldLY/s400/leds.jpg&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5615180451176543154&quot; style=&quot;cursor: pointer; width: 400px; height: 303px; &quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;EL CODIGO&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;Un simple programa que permite iluminar 7 leds. El código está definido con 6 procedimientos:&lt;br /&gt;&lt;br /&gt;- ledOff(): Pone las salidas 0-6 en LOW&lt;br /&gt;- secuencia1(): hace una secuencia del pin 0 al 6 con 10 ms de retardo&lt;br /&gt;- secuencia2(): hace una secuencia del pin 6 al 0 con 10 ms de retardo&lt;br /&gt;- secuencia3(): enciende los leds impares y hace flash en los pares&lt;br /&gt;- secuencia4(): enciende los leds pares y hace flash en los impares&lt;br /&gt;- secuencia5(): hace flash alternativo entre los leds pares e impares&lt;br /&gt;&lt;br /&gt;//Playing with leds&lt;br /&gt;byte const pines[]={0,1,2,3,4,5,6};&lt;br /&gt;byte pausa1, pausa2;&lt;br /&gt;&lt;br /&gt;void ledOff()&lt;br /&gt;{&lt;br /&gt;byte i;&lt;br /&gt;for (i=1;i&amp;lt;7;i++)&lt;br /&gt;digitalWrite(pines[i-1],LOW);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void setup()&lt;br /&gt;{&lt;br /&gt;byte i;&lt;br /&gt;for (i=0;i&amp;lt;7;i++)&lt;br /&gt;pinMode(pines[i],OUTPUT);&lt;br /&gt;pausa1=10;&lt;br /&gt;pausa2=50;&lt;br /&gt;ledOff();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void secuencia1()&lt;br /&gt;{&lt;br /&gt;byte i;&lt;br /&gt;ledOff();&lt;br /&gt;for (i=1;i&amp;lt;7;i++)&lt;br /&gt;{&lt;br /&gt;digitalWrite(pines[i-1],HIGH);&lt;br /&gt;delay(pausa1);&lt;br /&gt;digitalWrite(pines[i-1],LOW);&lt;br /&gt;delay(pausa1);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void secuencia2()&lt;br /&gt;{&lt;br /&gt;byte i;&lt;br /&gt;ledOff();&lt;br /&gt;for (i=7;i&amp;gt;=1;i--)&lt;br /&gt;{&lt;br /&gt;digitalWrite(pines[i-1],HIGH);&lt;br /&gt;delay(pausa1);&lt;br /&gt;digitalWrite(pines[i-1],LOW);&lt;br /&gt;delay(pausa1);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void secuencia5()&lt;br /&gt;{&lt;br /&gt;byte i;&lt;br /&gt;ledOff();&lt;br /&gt;for (i=0;i&amp;lt;7;i++)&lt;br /&gt;{&lt;br /&gt;digitalWrite(pines[0],HIGH);&lt;br /&gt;digitalWrite(pines[2],HIGH);&lt;br /&gt;digitalWrite(pines[4],HIGH);&lt;br /&gt;digitalWrite(pines[6],HIGH);&lt;br /&gt;delay(pausa2);&lt;br /&gt;digitalWrite(pines[0],LOW);&lt;br /&gt;digitalWrite(pines[2],LOW);&lt;br /&gt;digitalWrite(pines[4],LOW);&lt;br /&gt;digitalWrite(pines[6],LOW);&lt;br /&gt;delay(pausa2);&lt;br /&gt;digitalWrite(pines[1],HIGH);&lt;br /&gt;digitalWrite(pines[3],HIGH);&lt;br /&gt;digitalWrite(pines[5],HIGH);&lt;br /&gt;delay(pausa2);&lt;br /&gt;digitalWrite(pines[1],LOW);&lt;br /&gt;digitalWrite(pines[3],LOW);&lt;br /&gt;digitalWrite(pines[5],LOW);&lt;br /&gt;delay(pausa2);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void secuencia3()&lt;br /&gt;{&lt;br /&gt;byte i;&lt;br /&gt;ledOff();&lt;br /&gt;digitalWrite(pines[0],HIGH);&lt;br /&gt;digitalWrite(pines[2],HIGH);&lt;br /&gt;digitalWrite(pines[4],HIGH);&lt;br /&gt;digitalWrite(pines[6],HIGH);&lt;br /&gt;for (i=0;i&amp;lt;7;i++)&lt;br /&gt;{&lt;br /&gt;digitalWrite(pines[1],HIGH);&lt;br /&gt;digitalWrite(pines[3],HIGH);&lt;br /&gt;digitalWrite(pines[5],HIGH);&lt;br /&gt;delay(pausa2);&lt;br /&gt;digitalWrite(pines[1],LOW);&lt;br /&gt;digitalWrite(pines[3],LOW);&lt;br /&gt;digitalWrite(pines[5],LOW);&lt;br /&gt;delay(pausa2);&lt;br /&gt;}&lt;br /&gt;digitalWrite(pines[0],LOW);&lt;br /&gt;digitalWrite(pines[2],LOW);&lt;br /&gt;digitalWrite(pines[4],LOW);&lt;br /&gt;digitalWrite(pines[6],LOW);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void secuencia4()&lt;br /&gt;{&lt;br /&gt;byte i;&lt;br /&gt;ledOff();&lt;br /&gt;digitalWrite(pines[1],HIGH);&lt;br /&gt;digitalWrite(pines[3],HIGH);&lt;br /&gt;digitalWrite(pines[5],HIGH);&lt;br /&gt;for (i=0;i&amp;lt;7;i++)&lt;br /&gt;{&lt;br /&gt;digitalWrite(pines[0],HIGH);&lt;br /&gt;digitalWrite(pines[2],HIGH);&lt;br /&gt;digitalWrite(pines[4],HIGH);&lt;br /&gt;digitalWrite(pines[6],HIGH);&lt;br /&gt;delay(pausa2);&lt;br /&gt;digitalWrite(pines[0],LOW);&lt;br /&gt;digitalWrite(pines[2],LOW);&lt;br /&gt;digitalWrite(pines[4],LOW);&lt;br /&gt;digitalWrite(pines[6],LOW);&lt;br /&gt;delay(pausa2);&lt;br /&gt;}&lt;br /&gt;digitalWrite(pines[1],LOW);&lt;br /&gt;digitalWrite(pines[3],LOW);&lt;br /&gt;digitalWrite(pines[5],LOW);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void loop()&lt;br /&gt;{&lt;br /&gt;byte j;&lt;br /&gt;for (j=0;j&amp;lt;7;j++)&lt;br /&gt;secuencia1();&lt;br /&gt;for (j=0;j&amp;lt;7;j++)&lt;br /&gt;secuencia2();&lt;br /&gt;secuencia3();&lt;br /&gt;secuencia4();&lt;br /&gt;secuencia5();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;b&gt;EL RESULTADO&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;El siguiente video muestra el resultado de cargar este programa en el pinguino y ejecutarlo conectado al breadboard con los 7 leds.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;http://www.youtube.com/watch?v=Af7sBj24WcA&quot;&gt;Playing with leds&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adirgan.blogspot.com/feeds/2523679158068133282/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://adirgan.blogspot.com/2011/06/playing-with-leds.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/2523679158068133282'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/2523679158068133282'/><link rel='alternate' type='text/html' href='http://adirgan.blogspot.com/2011/06/playing-with-leds.html' title='Playing with LEDS'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/15931139500048857110</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoaGL5VltpXJ99oWsgRkGeVsUQQlsUGpRV9hzi6Wtc5Zxa_6Od0SRcSbgqauOjOXH1PL7oOqTwaRxx6aR9rkBw4KLjKj-1a8Onm7nDa3gQeGxwUkvO3a94cbXk_GvyDXHLkov58VmldLY/s72-c/leds.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192187322732553132.post-4363687123578134221</id><published>2011-05-22T12:44:00.000-07:00</published><updated>2011-05-22T17:07:43.954-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="digital output"/><category scheme="http://www.blogger.com/atom/ns#" term="dirgan"/><category scheme="http://www.blogger.com/atom/ns#" term="led"/><category scheme="http://www.blogger.com/atom/ns#" term="microncontroller"/><title type='text'>Salida Digital - Encender y apagar un led</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;El Hola Mundo que les propongo es utilizar un puerto de salida digital para encender y apagar un led con una secuencia definida.&lt;/div&gt;&lt;br /&gt;Empezaremos por alistarnos para ejecutar un demo de utilización de la salida digital de un microcontrolador. A continuación lo que requerimos para hacer nuestro hola mundo.&lt;br /&gt;&lt;br /&gt;1) El ambiente de desarrollo instalado en nuestro computador del microcontrolador que hallamos escogido.&lt;br /&gt;&lt;br /&gt;2) El microcontrolador que hallamos comprado o construido por nosotros mismo (DIY)&lt;br /&gt;&lt;br /&gt;3) Un led de cualquier color&lt;br /&gt;&lt;br /&gt;4) Un protoboard (opcional)&lt;br /&gt;&lt;br /&gt;Utilizar una salida digital de nuestro micro requiere que sepamos cuales son puertos de e/s digitales y analógicos. Para ello lo primero que debemos hacer es obtener el mapa de entrada y salida de nuestro hardware. Este lo podemos obtener desde la páqina web del fabricante del mismo.&lt;div&gt;&lt;br /&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikZLTvUKcGkqlL9gXiD1mpXMeBT7JotQ2DN10hOcP-wumKYBWhWIfQCOoVQG5W48jQaRBQFInusXwKprfwKxITYtqidVo5ApBEr-_3MpxwVl4wAPmL0ADsNAMbOgqt-8nYbpXsLYNVNcM/s1600/pinguino-2550.jpg&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikZLTvUKcGkqlL9gXiD1mpXMeBT7JotQ2DN10hOcP-wumKYBWhWIfQCOoVQG5W48jQaRBQFInusXwKprfwKxITYtqidVo5ApBEr-_3MpxwVl4wAPmL0ADsNAMbOgqt-8nYbpXsLYNVNcM/s400/pinguino-2550.jpg&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5609640582640520386&quot; style=&quot;float: right; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 10px; cursor: pointer; width: 273px; height: 400px; &quot; /&gt;&lt;/a&gt;Para nuestro hola mundo he escogido utilizar una plataforma de prototipado rápido basado en el PIC18f2550 (pinguino). El mismo lo construí hace un tiempo y lo he utilizado por algunos meses con todo éxito.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;El mapa de E/S de este microcontrolador lo podemos ver en la figura. Los puertos 0-10 son puertos que permiten tanto la entrada digital como la salida digital.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Los puertos 11-12 permiten entrada digital pero su salida es analógica. Los puertos 13-17 permiten entradas analógicas y salidas digitales.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;asimismo vemos dos puertos que nos ofrecen tierra y VCC 5V, lo cuales podemos utilizar para darle energía a nuestro led.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Teniendo claro el mapa de puertos y que hace cada uno, es mas fácil ejecutar la siguiente tarea: Armar el circuito básico.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;El protoboard es opcional ya que si ven el mapa, pudiéramos colocar el led directamente entre tierra (gnd) y el puerto 9. El puerto nueve permite salida digital (0-5V/0-1), por lo que si queremos encenderlo colocamos el puerto nueve en high (1 o 5V). Si queremos el led apagado colocamos el puerto 9 en low (0 o 0V).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;El led debe soportar la corriente que el micro le estregará. Si no es el caso, habría que colocar un limitador de corriente, el cual sería una resistencia. Para este ejemplo no la requeriremos ya que el led que utilizamos puede manejar la corriente que el micro le entrega.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0Sd0iU76WfR2a9t58XYuJwHLYAOPrzyV7_8Xm1CL6yxeFIp2Nfv3S3D4SEXA1VkFAVjLTuc-LGvmQkV4JL9bDMxvhRfTJ1r7HRKeoN7_CPMphMHKBs8JqujA7IF9gf8ppujTwdcx9PlQ/s1600/led.png&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;/a&gt;&lt;div&gt;El diagrama muestra la conexión si utilizáramos un protoboard. En este caso el ánodo del led (el terminal posivo) lo conectamos al puerto 9 y el cátodo, o terminal negativo, lo conectamos a tierra (GND).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEig9bz_cGgwS3EDQ_U-LerZPSMOPwbuxHztGo4fGrbdnejIhNli-6mytRND0obAgTMmNlhzv1KzI9WVsCjqcBKvCwsJmpl_VZ4oKaAaTT7TywHLvhZpNqwOXReicEgAxThyl8vN7F-mijk/s1600/led.png&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEig9bz_cGgwS3EDQ_U-LerZPSMOPwbuxHztGo4fGrbdnejIhNli-6mytRND0obAgTMmNlhzv1KzI9WVsCjqcBKvCwsJmpl_VZ4oKaAaTT7TywHLvhZpNqwOXReicEgAxThyl8vN7F-mijk/s320/led.png&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5609659846989881666&quot; style=&quot;float: left; margin-top: 0px; margin-right: 10px; margin-bottom: 10px; margin-left: 0px; cursor: pointer; width: 320px; height: 290px; &quot; /&gt;&lt;/a&gt;&lt;div&gt;                                      &lt;img src=&quot;http://upload.wikimedia.org/wikipedia/commons/thumb/c/c9/LED%2C_5mm%2C_green_%28int%29.svg/200px-LED%2C_5mm%2C_green_%28int%29.svg.png&quot; alt=&quot;LED, 5mm, green (int).svg&quot; /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Una vez conectado estamos listos para programar al microcontrolador. Para hacer un programa que prenda y apague un led de forma periódica solo requiere de unas pocas líneas de programación, pero requerimos entender un poco la arquitectura de un programa en el lenguaje que usa Arduino y sus parientes.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Anatomía de un Sketch&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Un programa o sketch de Arduino tiene tres partes fundamentales:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;1) Sección de encabezados&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Esta sección se utiliza para inicializar variables, definir constantes o invocar librerías.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;2) Sección de Setup&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Esta sección, la cual se ejecuta una sola vez, permite ejecutar aciones o asignarle valores a variables que se requieren para su utilización en la ejecución del programa.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;3) Sección de Ejecución Continua&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;En esta sección, la cual se ejecuta continuamente, se colocan las líneas de programa que son requeridas para definir el comportamiento del proyecto.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Veamos como encender intermitentemente un led en un skecth de Arduino.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;#define ledPort 9&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;&lt;br /&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;void setup(void)&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;{&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;   &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;pinMode(ledPort,OUTPUT);&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;// pin 9 como salida&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;}&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;&lt;br /&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;void loop(void)&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;{&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;   digitalWrite(ledPort,HIGH);&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;   delay(500);&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;   digitalWrite(ledPort,LOW);&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;   delay(500);&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;}&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;El skecth que acabamos de listar muestra las tres partes fundamentales de cualquier sketch de arduino.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;En el encabezado definimos una variable la cual indicará el puerto en donde conectaremos el ánodo del led. En nuestro caso ledPort mantendrá el valor 9, indicando el puerto número 9 el cual permite una salida digital.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;En la sección Setup, la cual es una procedimiento llamado setup(), definimos la caraterística de nuestro puerto. Cada puerto debe definirse como una entrada o una salida. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Como nuestra intención es usar el puerto para encender o apagar un led, el puerto debe configurarse como una salida.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;La instrucción &lt;i&gt;pinMode(ledPort,OUTPUT) p&lt;/i&gt;&lt;i&gt;ermite definir a través de una constante (OUTPUT) que el puerto 9 será utilizado como puerto de salida.&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;Finalmente definimos la sección loop, la cual es otro procedimiento, pero este se ejecuta continuamente (mientras el microprocesador esté energizado). En esta sección típicamente colocamos instrucciones que se ejecutarán de forma cíclica y que definirán el comportamiento.&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;En nuestro ejemplo, utilizamos el comando digitalWrite indicando en que puerto debemos escribir la constante HIGH. Esta constante escribe en el puerto un valor alto (1) para colocarlo en 5V, lo cual será la salida.&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;Luego utilizamos el comando delay(500), cuyo argumento indica los milisegundos que el programa o sketch suspende su ejecución, para luego reanudar con la ejecución del comando que apaga el led.&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;digitalWrite(ledPort, LOW) escribe en el puerto un valor bajo (0) para colocar el puerto en 0V, lo cual apagará el led. Luego de este comando se ejecuta de nuevo delay(500) para suspender la ejecución del sketch por 500ms.&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;Esto ejecutado continuamente tiene como efecto la intermitencia del led cada 500ms o medio segundo.&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;Una vez escrito el programa en el ambiente de desarrollo se debe compilar para convertir el programa de alto nivel en un formato que pueda exportarse al microcontrolador para su ejecución.&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjB0WvQydEQobrUgnNS_X0R2vIdP5iJSe6-F8EU7rMpLu1mojuDngYywSIZ1L4dm1hrtshfjp071PyNj7bhB3WXpgNLOK2H283k-zYBnkH2eSFAVEBgbG0h04xE7yLlMDT8keQXH8-Ae0I/s1600/led0.jpg&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjB0WvQydEQobrUgnNS_X0R2vIdP5iJSe6-F8EU7rMpLu1mojuDngYywSIZ1L4dm1hrtshfjp071PyNj7bhB3WXpgNLOK2H283k-zYBnkH2eSFAVEBgbG0h04xE7yLlMDT8keQXH8-Ae0I/s400/led0.jpg&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5609677606339694226&quot; style=&quot;float: left; margin-top: 0px; margin-right: 10px; margin-bottom: 10px; margin-left: 0px; cursor: pointer; width: 297px; height: 400px; &quot; /&gt;&lt;/a&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;Lo primero que debemos hacer es presionar el botón circunscrito en el recuadro rojo. La compilación puede tener dos resultados.&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;Mostrar errores o mostrar el mensaje que vemos en la parte inferior del ambiente de desarrollo, el cual muestra los mensajes que el compilador emite.&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;En nuestro caso, el mensaje obtenido es:&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;Compilation Done...&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;y luego muestra la cantidad de bytes que el programa ocuparía en memoria y el total de la memoria (en bytes) que el procesador tiene disponible para sketchs.&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;Adicionalmente indica en porcentaje la memoria utilizada.&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;Una vez compilado el programa se encuentra listo para ser exportado al dispositivo.&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;Conectamos el dispositivo a través de su puerto USB a nuestro computador. El procedimiento estándar de grabar el sketch en el micro es presionando el botón de reset del micro y pulsar el botón de escribir (ver figura) un par de segundos luego de haber presionado el botón de reset.&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;Lo que sucede en este pequeño intervalo de tiempo, es que el micro se presenta a través del puerto USB y el ambiente de desarrollo puede contactar el dispositivo y pasarle el archivo .hex, gracias al bootloader que tiene implementado el microcontrolador.&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;Luego de pasar el programa al micro también veremos un mensaje en el área de mensajes del IDE. En nuestro ejemplo podemos ver:&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Processing device 005&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;erasing section [2000, 7fff]&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;writing section [2000, 7fff]&lt;/div&gt;&lt;/i&gt;&lt;/div&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;Lo que indica que no hay errores, y que el dispositivo descubierto con identificación 05, se borró totalmente (en su área de de programa) y se re-escribió con el programa.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;Pinguino tiene 2 leds on board. Un led está destinado a indicar que el micro está energizado, por lo que desde se conecta al computador este led enciende. El otro led es el testigo de ejecución de programa. Este solo enciende luego que el micro se conecta y pasan 5 segundos y se ejecuta el programa que tiene grabado.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;Por tanto, luego de grabar el skecth, el micro tardará unos segundo antes de empezar a ejecutar automaticamente el mismo. Este comportamiento se repetirá cada vez que se encienda el dispositivo.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;Para este ejemplo, y si todo está ok, el led conectado el pinguino empezará parpadear con medio segundo entre encendido y apagado. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;320&#39; height=&#39;266&#39; src=&#39;https://www.blogger.com/video.g?token=AD6v5dzyx3m7LMSlYTHF9jg5XElSh6XLlSyEe7FiA6OXiOAwU9vpQVN0M4iP3D97xtRr8WDvK4p9kuHDwCERvCFvMQ&#39; class=&#39;b-hbp-video b-uploaded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adirgan.blogspot.com/feeds/4363687123578134221/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://adirgan.blogspot.com/2011/05/salida-digital-encender-y-apagar-un-led.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/4363687123578134221'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/4363687123578134221'/><link rel='alternate' type='text/html' href='http://adirgan.blogspot.com/2011/05/salida-digital-encender-y-apagar-un-led.html' title='Salida Digital - Encender y apagar un led'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/15931139500048857110</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikZLTvUKcGkqlL9gXiD1mpXMeBT7JotQ2DN10hOcP-wumKYBWhWIfQCOoVQG5W48jQaRBQFInusXwKprfwKxITYtqidVo5ApBEr-_3MpxwVl4wAPmL0ADsNAMbOgqt-8nYbpXsLYNVNcM/s72-c/pinguino-2550.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192187322732553132.post-4507640430629238438</id><published>2011-05-18T15:48:00.000-07:00</published><updated>2011-05-18T17:17:27.418-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="dirgan"/><category scheme="http://www.blogger.com/atom/ns#" term="Introduction"/><category scheme="http://www.blogger.com/atom/ns#" term="pinguino"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><category scheme="http://www.blogger.com/atom/ns#" term="robotic"/><category scheme="http://www.blogger.com/atom/ns#" term="teensy"/><title type='text'>Arduino and relatives - 101</title><content type='html'>&lt;a href=&quot;http://www.pjrc.com/teensy/breadboard_leds.jpg&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;http://radar.oreilly.com/assets_c/2011/03/ArduinoUnoFront-thumb-486x362.jpg&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;img style=&quot;float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 243px; height: 181px;&quot; src=&quot;http://radar.oreilly.com/assets_c/2011/03/ArduinoUnoFront-thumb-486x362.jpg&quot; border=&quot;0&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;Los componentes básicos de una plataforma Arduino o relacionados son, en primer lugar el hardware con el cual vamos a interactuar.&lt;br /&gt;&lt;br /&gt;En nuestro contexto, y basándonos en artículos anteriores, es el microcontrolador. Veamos algunos de ellos.. todos basados en su precursor y más evolucionado ancestro- Arduino.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;La imagen muestra un Arduino UNO. Esta plataforma de desarrollo presenta un número considerable de puertos de entrada y de salida para interactuar con el micro y un puerto USB para contectarlo con nuestro ordenador y poder programarlo o comunicarnos con El vía protocolo serial sobre el USB.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Generalmente utilizamos la energía del puerto USB (+5V) para alimentar el hardware, es decir, conectándolo al ordenador lo energizamos para poder programar el dispositivo.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Algunos parientes de Arduino los podemos encontrar en la red. Por ejemplo el Teensy permite trabajar como lo haríamos con Arduino pero a menor costo.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;a href=&quot;http://www.pjrc.com/teensy/breadboard_leds.jpg&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;img style=&quot;width: 500px; height: 150px;&quot; src=&quot;http://www.pjrc.com/teensy/breadboard_leds.jpg&quot; border=&quot;0&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;Los componentes se mantienen muy similares. Un puerto USB que energiza el componente de hardware y permite comunicarnos con El, así como puertos de entrada y salida para ponerlo a hacer algo con el exterior.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Pinguino, como comentaba en un artículo anterior, es una plataforma muy parecida a las anteriores, con la diferencia fundamental de que está basado en un micro PIC. Es muy sencillo de ensamblar desde cero y es muy barato de implementar.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;img style=&quot;width: 500px; height: 253px;&quot; src=&quot;http://www.hackinglab.org/pinguino/image/pinguino4.jpg&quot; /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Adicionalmente a los puertos de entrada/salida y USB, podemos encontrar un botón que nos permite resetear el dispositivo. Resetear el mismo permite:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Llevar al dispositivo a un estado consistente de inicio.&lt;/li&gt;&lt;li&gt;Ejecutar desde cero el programa cargado en El.&lt;/li&gt;&lt;li&gt;Generalmente, existe un delta de tiempo antes de iniciar el programa cargado en un micro, que nos permite pasar del IDE  el archivo .hex producto de la compilación del programa con el cual deseamos cargarlo. Por tanto, si queremos reprogramar el dispositivo utilizamos el botón de reset y el IDE.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;Para más info de arduino pueden ir a esta &lt;a href=&quot;http://arduino.cc/en/Guide/Introduction&quot;&gt;introducción&lt;/a&gt;.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;El segundo componente es el IDE, en el cual programamos, compilamos y cargamos nuestro programa en el dispositivo.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;El IDE puede verse de la siguiente forma.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;img src=&quot;http://shop.gtronica.com/images/categories/desenvolvimento/arduino-ide.gif&quot; /&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;También llamado ambiente de desarrollo, el mismo consta de:&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Editor de Texto, el cual nos permite escribir nuestro código.&lt;/li&gt;&lt;li&gt;Area de Mensajes, en donde recibimos los mensajes de compilación y en algunos casos las salidas de la comunicación del dispositivo vía serial.&lt;/li&gt;&lt;li&gt;Area de Botones, los cuales nos permiten compilar y cargar nuestro .hex en el dispositivo.&lt;/li&gt;&lt;li&gt;Menú, en donde conseguiremos las opciones que el IDE nos ofrece.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;El código en arduino se denomina Sketch, lo cual es un nombre diferente a lo que nosotros estamos acostumbrados, pero básicamente es lo mismo que un programa.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Para mayor referencia del ambiente de desarrollo pueden entrar aqui (&lt;a href=&quot;http://www.arduino.cc/en/Guide/Environment&quot;&gt;IDE&lt;/a&gt;).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Estos dos componentes básicos son indivisibles si queremos desarrollar, aunque si tenemos el dispositivo programado y en producción, el ambiente de desarrollo no es necesario... solo la energía para alimentar al dispositivo utilizado.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Para obtener el componente de hardware tenemos básicamente dos (2) opciones: lo compramos o lo fabricamos. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Arduino y sus parientes son plataformas de hardware abierto, lo que nos permite obtener los diseños en las páginas web de los fabricantes y fabricarlos nosotros mismos (DIY - Do It Yourself).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Existe toda una tendencia hoy para los que nos gusta tomar los planos o esquemáticos y ejecutar desde cero... los DIYers y los Tinkerers. Los primeros ya los intuimos, los segundos son personas que les gusta reparar y/o esperimentar con máquinas y sus partes.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lo más sencillo sin duda alguna es buscar algún proveedor local y obtener inicialmente el más modesto de los dispositivos. También podemos fabricarlos, como lo he hecho yo con pinguino... pero esa es otra historia.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Otros componentes de hardware que debemos buscar con nuestro proveedor de electrónica son:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lista Básica para iniciarnos con un Hello World y entreternernos con algunos ejemplos simples para poder aprender.&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Protoboard&lt;/li&gt;&lt;li&gt;Algunos leds&lt;/li&gt;&lt;li&gt;Algunas resistencias de 470 Ohm&lt;/li&gt;&lt;li&gt;1 potenciometro de 10K Ohm&lt;/li&gt;&lt;li&gt;1 switch&lt;/li&gt;&lt;li&gt;1 pulsador&lt;/li&gt;&lt;li&gt;cables&lt;/li&gt;&lt;li&gt;y algunas herramientas básicas como una pinza y un cortafrio y un tester&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;Les aseguro que esta lista empezará a crecer muy rápido en lo que le tomen el gusto a esto.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;El segundo componente lo obtenemos del fabricante directamente. En las páginas de &lt;a href=&quot;http://arduino.cc/en/Main/Software&quot;&gt;Arduino&lt;/a&gt;, &lt;a href=&quot;http://www.pjrc.com/teensy/td_download.html&quot;&gt;teensy&lt;/a&gt; y &lt;a href=&quot;http://www.hackinglab.org/pinguino/download/latestpinguino/&quot;&gt;pinguino&lt;/a&gt; podrán conseguir los links desde donde bajarse la versión que más se ajuste al sistema operativo de su preferencia.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;En mi caso trabajo con Linux, y aunque es un poco más elaborada la instalación en estos ambientes operativos, no es dificil realmente, aunque en Windows siempre es muy sencillo e intuitivo.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Como lectura complementaria les dejo:&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;&lt;a href=&quot;http://radar.oreilly.com/2011/05/arduino-open-hardware-movement.html&quot;&gt; The secret is to bang the rocks together&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;What you can do with Processing and Arduino&quot;&gt;What you can do with Processing and Arduino&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;No pierdan de vista a Processing... lo estaremos usando para hacer cosas muy interesantes.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;&lt;/span&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adirgan.blogspot.com/feeds/4507640430629238438/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://adirgan.blogspot.com/2011/05/arduino-and-relatives-101.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/4507640430629238438'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/4507640430629238438'/><link rel='alternate' type='text/html' href='http://adirgan.blogspot.com/2011/05/arduino-and-relatives-101.html' title='Arduino and relatives - 101'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/15931139500048857110</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192187322732553132.post-8749268945619672569</id><published>2011-05-15T16:17:00.000-07:00</published><updated>2011-05-16T15:18:31.665-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="design"/><category scheme="http://www.blogger.com/atom/ns#" term="dirgan"/><category scheme="http://www.blogger.com/atom/ns#" term="interactivity"/><category scheme="http://www.blogger.com/atom/ns#" term="Introduction"/><category scheme="http://www.blogger.com/atom/ns#" term="microcontroller"/><category scheme="http://www.blogger.com/atom/ns#" term="pic"/><category scheme="http://www.blogger.com/atom/ns#" term="pinguino"/><category scheme="http://www.blogger.com/atom/ns#" term="pwm"/><category scheme="http://www.blogger.com/atom/ns#" term="robotic"/><category scheme="http://www.blogger.com/atom/ns#" term="teensy"/><title type='text'>Arduino o No Arduino</title><content type='html'>&lt;div&gt;En  artículos anteriores hemos avanzado en el tema teórico de los  microcontroladores, lo cual es &quot;Nice&quot; cuando queremos introducirnos a un  terreno donde nunca hemos estado. Habiéndolo recorrido con suficiente  extensión desde una perspectiva de hobby, creo ya conveniente que  vayamos directo a la experimentación.&lt;br /&gt;&lt;br /&gt;Pero no iremos directamente  a experimentar sin antes escoger que tecnología debemos usar para,  desde mi punto de vista, cumplir con tres objetivos:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1) Ser sencillo&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Esto  es muy importante. Yo soy un fiel creyente que se pueden hacer cosas  muy interesantes y útiles sin la necesidad de ser un ingeniero... solo  hay que tener conocimientos básicos, ser ávido lector, y tener  suficiente curiosidad como para escudriñar temas y llegar a su núcleo  para entenderlos lo suficiente como para empezar a crear.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2) Ser Amplio&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Tener capacidad de ser utilizado en múltiples aplicaciones.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3) Estar al Alcance&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Ser una tecnología accesible a cualquier en muchas partes del mudo, y sobre todo en nuestros países latinoamericanos.&lt;br /&gt;&lt;br /&gt;Cuando  inicié a investigar acerca de los micros, lo primero que conseguí fue  información del microcontrolador más popular de todos los tiempos... el  PIC. De este se consiguen todos los modelos y tamaños (pines, memoria,  etc), y aunque es relativamente sencillo aprender a programarlos, no  cumple fielmente con mi primer objetivo... ser sencillo.&lt;br /&gt;&lt;br /&gt;Recuerdo  que después de algunas semanas leyendo acerca de ellos y trabajando en  simuladores pensé... debe haber otras tecnologías que permitan hacer lo  mismo de manera más rápida y sencilla. Con esta idea en mente empecé a  buscar como hacer algo basado en PIC que me permitiera no tener que  adquirir un programador especializado y además que fuese sencillo... y  dando vueltas en la red conseguí a &lt;a href=&quot;http://www.arduino.cc/&quot;&gt;&lt;b&gt;Arduino&lt;/b&gt;&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&quot;Arduino  is an open-source electronics prototyping platform based on flexible,  easy-to-use hardware and software. It&#39;s intended for artists, designers,  hobbyists, and anyone interested in creating interactive objects or  environments.&quot;&lt;br /&gt;&lt;br /&gt;Y en el pequeño concepto obtenido de su página web  vemos algo clave: prototyping. Esta es una herramienta de prototipado  rápido, lo que permite llevar un concepto de la idea a la práctica de  forma muy rápida, además de ser sencillo y flexible, y es  suficientemente multipropósito como para cubrir al menos los objetivos 1  y 2.&lt;br /&gt;&lt;br /&gt;Inmediatamente después de conseguir a Arduino me dediqué a  la tarea de averiguar si lo podía conseguir en algún lugar cercano a mi  residencia, lo cual efectivamente conseguí, por lo que el tercer  objetivo fue cumplido.&lt;br /&gt;&lt;br /&gt;Ahora bien, luego de tener mi primer  encuentro con Arduino decidí que este era el microcontrolador para mi, y  empecé a estudiarlo y recorrer la red para ver que había. Es asombroso  ver como una plataforma abierta puede ser tan masiva y tan apetecible  por expertos y principiantes.&lt;br /&gt;&lt;br /&gt;Siendo una plataforma abierta se  presta para que mucha gente desarrolle y cree cosas nuevas, además de  plataformas afines (no clones) que pueden ser alternativas válidas de  desarrollo.&lt;br /&gt;&lt;br /&gt;Lo interesante de arduino es que ha creado todo un  ambiente de desarrollo basado en un lenguaje de programación muy  intuitivo y una forma de interactuar con el dispositivo realmente  sencillo, por lo que los desarrollos alternativos han buscado aprovechar  este esquema y reproducirlo, lo cual permite que alguien que ha  estudiado arduino pueda con muy poco esfuerzo intelectual hacer las  mismas cosas que con arduino.&lt;br /&gt;&lt;br /&gt;Navegando en la red me topé entonces con &lt;a href=&quot;http://www.pjrc.com/teensy/&quot;&gt;&lt;b&gt;Teensy&lt;/b&gt;&lt;/a&gt;.  Esta es una plataforma alternativa a arduino mucho más económica y con  prestancias similares, a lo cual respondí comprando un Teensy 2.0+.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Luego, buscando cosas acerca de esta plataforma conseguí algo que me pareció más interesante aún... conseguí a &lt;a href=&quot;http://www.hackinglab.org/&quot;&gt;&lt;b&gt;Pinguino&lt;/b&gt;&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Esta  plataforma es un clone de arduino pero basado en el microcontrolador  PIC, además de ser muy simple de implementar desde el punto de vista de  hardware. Cuando hablo de un clone es que el look-and-feel de su  lenguaje de programación, así como la interacción con el micro es muy  parecida (para no decir igual) a arduino, lo que permite tener una  plataforma de prototipado rápido adicional, amén que es muy barato  construir los dos modelos propuestos en hackinglabs.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Pero entonces cual escoger?. Arduino o No Arduino?... esa es la cuestión.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Como  mi intención es aprender y escribir acerca de mis experiencias, y  pensando en los primeros tres objetivos, creo que el tema no es escoger a  arduino como plataforma sino como filosofía. Esto hace que uno pueda  comprar un arduino original o adquirir o construir cualquiera de las  plataformas alternativas que existen basados en la filosofía de arduino.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;En el próximo artículo iniciaremos a arduino y su filosofía y empezaremos a experimentar.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Antes de finalizar quisiera mostrar algo de verdad interesante... es tan masivo el tema de Arduino que hace poco Google lanzó una plataforma de desarrollo para Android basado en arduino.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Detalles en &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 51); font-family: arial, &#39;helvetica neue&#39;, helvetica, sans-serif; font-size: 14px; line-height: 16px; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;a href=&quot;http://developer.android.com/guide/topics/usb/adk.html&quot;&gt;Android Open Accessory Development Kit&lt;/a&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;English Section&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; font-size: 17px; &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; font-size: 17px; &quot;&gt;I&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;n previous articles we have advanced in the theoretical subject of the microcontrollers, which is &quot; Nice&quot; when we want to introduce ourselves to a land where we never have been. Having studied this subject with sufficient extension from a hobby perspective, I think it is the time to go directly to the experimentation arena. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;But we can&#39;t go to experimentation if we haven&#39;t choose which technology is the ideal technology to work on. From my point of view we have to fulfill three objectives first: &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;&lt;b&gt;1) Simple &lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;This is very important. I am a believing faithful that we can make very useful and interesting things without a Master Degree… The only prerequisites needed is basic knowledge, to be an eager reader, and to have sufficient curiosity to dig in subjects and to arrive at his core to understand them. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;&lt;b&gt;2) Ample &lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot;&gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot;&gt;Have the capacity to be used in multiple applications. &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;&lt;b&gt;3) everybody&#39;s reachable&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;Need to be an accessible technology to everybody in many parts of the world, and mainly in our Latin American countries. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot;&gt;When I started to investigate about microcontrollers, the first micro that came up was the PIC micro. You can find PIC in all mod&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot;&gt;els and sizes (pins, memory, etc), and although this technology is relatively simple to learn and program, does not fulfill my immediate goal faithfully… to be simple. &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;I remember that after some weeks reading about them and working over simulators I thought… there must have other technologies that allow me to do the same, faster and simpler. With this idea in mind I began to look for something based on PIC that allowed me to program them without a specialized burner and in addition, it had to be simple… and digging out on internet I got &lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, serif; &quot;&gt;&lt;a href=&quot;http://www.arduino.cc/&quot;&gt;&lt;b&gt;Arduino&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, serif; &quot;&gt;.&lt;/span&gt;. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;&quot;Arduino is an open-source electronics prototyping platform based on, easy-to-uses hardware and software. Its&#39; for intended artists, designers, hobbyists, and anyone interested in creating interactivates objects or environments.&quot; &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;At the small reading above obtained from its Web page we can see something that for me is the key: prototyping. This is a prototyping tool, which allows us to convert a concept from an idea to a final result in a very fast way. Additionally  it is simple, flexible, and it is multipurpose. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;Immediately after knowing Arduino I dedicated myself to the task of finding out if it could be obtained anywhere near to my place, which indeed I found, reason why the third objective was fulfilled. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;After to have my first encounter with Arduino I decided that this was the microcontroller for my projects, and began to study it and looked out on internet to see what is in there about this technology. It is amazing to see how an open platform can be so massive and so tempting for experts or beginners. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;As an open platform, a lot of people are developing and creating new things, additionally to create compatible platforms that can be a valid alternative for development.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;The most interesting thing of arduino is that the development environment is based on a very intuitive programming language and the way of interacting with the microcontroller is really simple, reason why alternative developments are adopting this technology more and more.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;Navigating internet, few days after, I found &lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, serif; &quot;&gt;&lt;a href=&quot;http://www.pjrc.com/teensy/&quot;&gt;&lt;b&gt;Teensy&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;. This is an alternative platform but far less expensive than arduino and with similar features, to which I responded buying a Teensy 2.0+. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;Then, looking for things related to this platform I obtained something even more interesting to me… &lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, serif; &quot;&gt;&lt;a href=&quot;http://www.hackinglab.org/&quot;&gt;&lt;b&gt;Pinguino&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;. This platform is a clone of arduino but based on PIC microcontroller, and it is very simple to implement from the hardware stand point. Understanding by clone that the look-and-feel of its programming language is practically the same as arduino environmet, as well as the interaction with the microcontroller, which allows us to have a fast prototyping platform and it is cheaper than teensy.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;But then what to choose?. Arduino or Not Arduino? … that is the question. As my intention is to learn and to write about my experiences, and thinking about the first three objectives, I believe that the goal is not to choose arduino as a platform, but a philosophy. This gives us the ability to have a wide number of platforms related to arduino, learning only one technology.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;In the next blog we are going to start introducing arduino and make some hello world examples and experimentation.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;... Arduino is so massive that Google launched a developing environment to Android based on Arduino... very nice.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; &quot; &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 51); font-family: arial, &#39;helvetica neue&#39;, helvetica, sans-serif; line-height: 16px; &quot; &gt;&lt;a href=&quot;http://developer.android.com/guide/topics/usb/adk.html&quot;&gt;Android Open Accessory Development Kit&lt;/a&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;</content><link rel='replies' type='application/atom+xml' href='http://adirgan.blogspot.com/feeds/8749268945619672569/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://adirgan.blogspot.com/2011/05/arduino-o-no-arduino.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/8749268945619672569'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/8749268945619672569'/><link rel='alternate' type='text/html' href='http://adirgan.blogspot.com/2011/05/arduino-o-no-arduino.html' title='Arduino o No Arduino'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/15931139500048857110</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192187322732553132.post-3682243851763412233</id><published>2011-04-01T12:36:00.001-07:00</published><updated>2011-04-28T18:07:12.864-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="design"/><category scheme="http://www.blogger.com/atom/ns#" term="dirgan"/><category scheme="http://www.blogger.com/atom/ns#" term="interactivity"/><category scheme="http://www.blogger.com/atom/ns#" term="Introduction"/><category scheme="http://www.blogger.com/atom/ns#" term="microcontroller"/><category scheme="http://www.blogger.com/atom/ns#" term="pic"/><category scheme="http://www.blogger.com/atom/ns#" term="pinguino"/><category scheme="http://www.blogger.com/atom/ns#" term="pwm"/><category scheme="http://www.blogger.com/atom/ns#" term="robotic"/><category scheme="http://www.blogger.com/atom/ns#" term="teensy"/><title type='text'>Microcontroladores - parte V - E/S</title><content type='html'>En  esta entrega estaremos ahondando un poco en los puertos de entrada y  salida de los microcontroladores, con ejemplos básicos de como  interactuar con ellos dependiendo de tu tipo, y por consiguiente de su  utilidad.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Pero antes una nota especial a este  artículo que conseguí en internet que habla de Limor Fried, una chica  cuyo objetivo ha sido impulsar el hardware de electrónica de línea  abierta. Muy interesante el artículo, pero aún más interesante es luego  ver la página de la empresa para la cual trabaja!... vean los siguientes  links.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;http://www.wired.com/magazine/2011/03/ff_adafruit/&quot;&gt;ARTICULO&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBmQa5vei6uAMl1MjT6NosXfvoTB8ei2yBUvdYft5v7iQ9yxgsiTHq9sCe556n13_eiS8BkM4qD8fhX6dF7mTPYxEFoBgZb4_oYa0wglVSzqk_oxB_-oQscODiGajQyGB6XZV45BnukWk/s200/wire.jpg&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5600804104305875922&quot; style=&quot;float: left; margin-top: 0px; margin-right: 10px; margin-bottom: 10px; margin-left: 0px; cursor: pointer; width: 200px; height: 148px; &quot; /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal; &quot;&gt;&lt;div style=&quot;display: inline !important; &quot;&gt;&lt;b&gt;PUERTOS DE ENTRADA Y SALIDA&lt;/b&gt;&lt;/div&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;Los  puertos de los microcontroladores son su sinapsis con el mundo  exterior. Los mismos permiten llevar datos a los micros u obtener datos  de ellos. &lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;La final&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;div style=&quot;font-weight: normal; display: inline !important; &quot;&gt;idad de un microcontrolador  al final es realizar tareas repetitivas (como cualquier computador)  ejecutando programas y respondiendo a estímulos externos.&lt;/div&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;En un computador, un software de diseño gráfico permite crear imágenes a partir de múltiples fuentes:&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;1)  Imágenes ya creadas por otros. En este caso la imagen es un archivo que  se encuentra en un periférico llamado disco (almacenamiento) y el mismo  está conectado al computador a través de un puerto (internos o  externos).&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;2) Inspiración del ejecutante. A  través del teclado y el mouse o cualquier otro dispositivo de  adquisición de información, el programa de diseño responde al input de  los mismos. El teclado está conectado a un puerto (interno o externo) y  el mouse seguramente estará conectado a un puerto USB.&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;3)  El usuario del programa de diseño obtiene feedback del mismo a través  de la pantalla, la misma es un dispositivo de salida conectada a un  puerto del computador.&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;4) El producto final de  la ejecución del programa de diseño seguramente será un archivo que  finalmente se guardará en un periférico de almacenamiento que está  conectado a un puerto de E/S del computador.&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;Como podemos observar de los puntos anteriores, un micro no se aleja de un computador en mucho.&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;Los puertos de E/S de un micro son entradas digitales o analógicas que nos permiten hacer diferentes actividades:&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;1)  Obtener datos de periféricos como switches, potenciómetros, celdas  fotoeléctricas, sensores de temperatura, sensores de humedad, sensores  de proximidad, Memorias EEPROM, dispositivos de conexión Wifi,  dispositivos de conexión alámbrica a internet, tarjetas para  lectura/escritura de memorias SD, Keypads, Lectores RFID, etc.&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;2)  Sacar datos del micro hacia diferentes periféricos tales como: leds,  reles, memorias EEPROM, displays LCD, altavoces, dispositivos con  interfaces serial, USB, I2C, 1Wire, etc.&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;Los datos de entrada/salida pueden venir en formatos: digitales o analógicos. &lt;/div&gt;&lt;div style=&quot;font-weight: normal; &quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal; &quot;&gt;&lt;div&gt;&lt;b&gt;Entradas Digitales&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Un  pin se define como entrada digital cuando este permite leer solo dos  estados. Valor lógico LOW o (0) cuando el pin está conectado a tierra.  Valor lógico HIGH o (1) cuando el pin está conectado a 5+ V.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Salidas Digitales&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;Un  pin se define como salida digital cuando este permite sacar solo dos  estados. Valor lógico LOW o (0) cuando el pin entrega 0V. Valor lógico  HIGH o (1) cuando el pin entrega 5+ V.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Entradas Analógicas&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;Un  pin se define como entrada análoga cuando este permite leer un rango de  voltaje entre 0V y +5V. Estos valores son mapeados hacia el  microcontrolador en un rango de valores numéricos entre 0 y 1023 o 0 y  255. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Para saber que voltaje se está leyendo en un pin analógico solo requerimos hacer una simple regla de 3. Por ejemplo:&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;0V equivale al valor 0 leído desde el micro&lt;/div&gt;&lt;div&gt;1V equivale al valor 204 leído desde el micro&lt;/div&gt;&lt;div&gt;2.5V equivale al valor 511 leído desde el micro&lt;/div&gt;&lt;div&gt;3.5V equivale al valor 716 leído desde el micro&lt;/div&gt;&lt;div&gt;5V equivale al valor 1023 leído desde el micro&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;b&gt;Salidas Analógicas&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;Un  pin se define como salida análoga cuando este permite variar el voltaje  del pin en un rango de voltaje entre 0V y +5V. Estos valores son  mapeados desde el microcontrolador en un rango de valores numéricos  entre 0 y 1023 o 0 y 255. &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;De forma  análoga a la entrada analógica, si queremos colocar un pin analógico en  un voltaje de 3.5V, solo tenemos que hacer el cálculo correspondiente,  que en nuestro ejemplo es el valor numérico 716 si utilizamos el rango  (0,1023).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Las salidas analógicas se trabajan  con una técnica llamada PWM o Pulse Width Modulation, el cual es una  técnica para obtener valores análogos a través de medios digitales. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;El  control digital es utilizado para crear una onda cuadrada, la cual  cambia periódicamente entre un estado ON y un estado OFF. Este patrón  ON-OFF puede simular un voltaje entre 5V y 0V cambiando la porción del  tiempo que la señal se mantiene en ON versus el tiempo que la misma se  mantiene en OFF. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;La duración que la señal esta  ON se denomina ancho del pulso. Para obtener valores de voltaje  diferentes hay que modular o cambiar el ancho del pulso (también llamado  ciclo de trabajo). Si esta modulación se hace lo suficientemente rápido  el efecto final es un voltaje que permite por ejemplo hacer que un LED  ilumine con diferentes intensidades de luminiscencia, o controlar un  motor de pulso o un servo.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;La siguiente  gráfica muestra algunos ejemplos de modulación del ancho de pulso con pic.&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;/div&gt;&lt;div&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;img src=&quot;http://www.best-microcontroller-projects.com/image-files/pwm.png&quot; alt=&quot;PWM pulse width modulation signal&quot; /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;En  general, los pines de los microcontroladores vienen con diferentes  capacidades, en diferentes proporciones. No todos los pines son  digitales o analógicos. Cada micro viene con la documentación para  determinar que pines usar de acuerdo a las tareas a realizar.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Si  requerimos encender o apagar un LED, hay que escoger un pin que sea  digital, el cual solo permite aplicar dos estados (ON,OFF) o (HIGH,  LOW).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Si requerimos controlar un servo debemos escoger un pin con salida analógica.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Si  requerimos leer un sensor de temperatura que entrega un rango de  voltaje entre 0V y 5V de acuerdo a la temperatura ambiente, debemos  escoger como entrada un pin análogo.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Esto  aplica para muchos micros del mercado, como por ejemplo PIC o AtMega,  así como generaciones posteriores que utilizan estos micros para  construir sobre ellos, microcontroladores ampliados que permiten hacer  lo mismo que los anteriormente mencionados pero de forma más amigable y  con lenguajes de alto nivel. Tal es el caso de Arduino el cual se basa  en AtMega, o Pinguino cuya plataforma es PIC.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Como  ejemplo podemos ver el siguiente código el cual enciende y apaga un LED  cada 300 milisegundos. Este ejemplo solo permite mostrar como utilizar  un pin como una salida. En próximas entregas estaremos empezando con el  &quot;Hola Mundo&quot; con dos de mis favoritos... Arduino y Pinguino, y  empezaremos formalmente a interactuar con ellos.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Código para Pinguino&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;b&gt;LEDBlink.pde&lt;/b&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;void setup()&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;{&lt;br /&gt;// Definimos el pin 0 como salida&lt;br /&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;   pinMode(0,OUTPUT);&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;}&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;&lt;br /&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;void loop()&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;{&lt;br /&gt;//Colocamos el pin 0 en 5V (encendemos el LED)&lt;br /&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;   digitalWrite(0,HIGH);&lt;br /&gt;//Establecemos una pausa de 300ms&lt;br /&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;   delay(300);&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, serif; text-align: left; &quot;&gt;&lt;div&gt;&lt;i&gt;   //Colocamos el pin 0 en 0V (apagamos el LED)&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;/span&gt;&lt;i&gt;   digitalWrite(0,LOW);&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, serif; text-align: left; &quot;&gt;&lt;div&gt;&lt;i&gt;   //Establecemos una pausa de 300ms&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;/span&gt;&lt;i&gt;   delay(300);&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;}&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt; Links de interés:&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;http://www.arduino.cc/&quot;&gt;Arduino&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;http://www.hackinglab.org/&quot;&gt;Pinguino&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Algunos conceptos (Wikipedia y otros)&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1) I²C es un bus de comunicaciones en serie. Su nombre viene de Inter-Integrated Circuit (Circuitos Inter-Integrados)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;http://es.wikipedia.org/wiki/I%C2%B2C&quot;&gt;Fuente: Wikipedia&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;2) 1-Wire es un protocolo de comunicaciones en serie diseñado por Dallas Semiconductor. Está basado en un bus, un maestro y varios esclavos de una sola línea de datos en la que se alimentan. Por supuesto, necesita una referencia a tierra común a todos los dispositivos.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;http://es.wikipedia.org/wiki/1-Wire&quot;&gt;Fuente: Wikipedia&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adirgan.blogspot.com/feeds/3682243851763412233/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://adirgan.blogspot.com/2011/04/microcontroladores-parte-v-es.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/3682243851763412233'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/3682243851763412233'/><link rel='alternate' type='text/html' href='http://adirgan.blogspot.com/2011/04/microcontroladores-parte-v-es.html' title='Microcontroladores - parte V - E/S'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/15931139500048857110</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBmQa5vei6uAMl1MjT6NosXfvoTB8ei2yBUvdYft5v7iQ9yxgsiTHq9sCe556n13_eiS8BkM4qD8fhX6dF7mTPYxEFoBgZb4_oYa0wglVSzqk_oxB_-oQscODiGajQyGB6XZV45BnukWk/s72-c/wire.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192187322732553132.post-5238444862636589028</id><published>2011-03-31T10:19:00.001-07:00</published><updated>2011-04-01T12:53:45.240-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="design"/><category scheme="http://www.blogger.com/atom/ns#" term="dirgan"/><category scheme="http://www.blogger.com/atom/ns#" term="interactivity"/><category scheme="http://www.blogger.com/atom/ns#" term="Introduction"/><category scheme="http://www.blogger.com/atom/ns#" term="microcontroller"/><category scheme="http://www.blogger.com/atom/ns#" term="pic"/><category scheme="http://www.blogger.com/atom/ns#" term="pwm"/><category scheme="http://www.blogger.com/atom/ns#" term="robotic"/><category scheme="http://www.blogger.com/atom/ns#" term="teensy"/><title type='text'>Microcontroladores - Parte IV</title><content type='html'>Después de mucho tiempo vuelvo a escribir algo... honestamente el trabajo no me deja mucho tiempo con fuerzas para experimentar y escribir.&lt;br /&gt;&lt;br /&gt;Hoy hablaremos de que debemos hacer para  que los microcontroladres se comporten o ejecuten las actividades que uno requiere para cierta aplicación.&lt;br /&gt;&lt;br /&gt;Pero antes... como es mi costumbre veamos algo interesante hecho con micros para entusiasmarnos con lo que se puede hacer.&lt;br /&gt;&lt;br /&gt;Esta vez es interesante pero algo soso, aunque habrá gente que le parezca impresionante.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.pcworld.com/article/222196/facebook_likes_this_legoarduino_hack_shows_your_likes.html&quot;&gt;Icono Like it de Facebook&lt;/a&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Pues esto es interesante solo como ilustración de lo que se puede hacer con un micro. En este caso es el icono de facebook que se pulsa cuando a alguien le gusta lo que uno cuelga en esta página. Lo interesante es que es como una lámpara hecha con legos, que se enciende cuando alguien presiona like it en algún post nuestro.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Veamos que hay detrás... Pues un arduino como microcontrolador para conectarse al computador y a través del API gráfico de Facebook y una librería diseñada para arduino, podemos hacer pooling de nuestros like it y encender la lámpara cuando esto sucede.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Algo que yo no sabía es que nosotros podemos diseñar nuestros legos y pedirlos a fábrica con un software que se baja de la página web de la LEGO. ESTO SI QUE ES INTERESANTE, sobre todo para robótica.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;http://designbyme.lego.com/en-us/Default.aspx&quot;&gt;LEGO Design by ME&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Bueno.. ahora a la materia.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Un microprocesador tiene la posibilidad de cambiar su comportamiento mediante la programación del mismo. En los viejos tiempos, el único lenguaje que se utilizaba para tal fin era el Assembler.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Este era el único lenguaje disponible por ese tiempo debido a la poca memoria con la que contaban los micros, por lo que el assembler era el lenguaje por excelencia, ya que el mismo no tiene los desperdicios que lenguajes de alto nivel introducen.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lo que es cierto, es que esto ha evolucionado y ya los temas de memoria no son tan neurágilcos. Por un lado, porque la memoria ha bajado de precio en los últimos años. A su vez los micros han evolucionado en capacidades y memoria, por lo que los lenguajes de alto nivel se han metido en este terreno... y debo ser honesto, a Dios gracias.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Trabajar en lenguaje de alto nivel es realmente una bendición, ya que podemos con nuestros conocimientos de la universidad, hacer trabajar a estos controladores. Desde que los lenguajes de alto nivel aparecieron en este terreno, han proliferado desde pascal, pasando por C y hasta Basic.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;En lo particular programo en C desde que tengo memoria y por tanto me ciento cómodo trabajando con el mismo. Pero entiendo que C no es del gusto popular, así que no problem, existen lenguajes como Pascal y Basic para los gustos restantes.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Algunos de los fabricantes con más éxito en este terreno se han especializado no solo en los compiladores sino en los ambientes de desarrollo. Tal es el caso de la gente de MikroElectronika.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;a href=&quot;http://www.mikroe.com/eng/home/index/&quot;&gt;&lt;img src=&quot;http://www.mikroe.com/img/logo.gif&quot; alt=&quot;MikroElektronika&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Esta gente tiene muy buenos compiladores y además, desde mi perspectiva, presentan la curva de aprendizaje más sencilla, al ocultar muchas particularidades y configuraciones que deben hacerse de acuerdo al micro que utilicemos.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;a href=&quot;http://www.mikroe.com/eng/products/view/7/mikroc-pro-for-pic/&quot;&gt;&lt;img src=&quot;http://www.mikroe.com/img/compilers/mikroc/pro/pic/default/mikroc-pro-thumb.gif&quot; alt=&quot;mikroC PRO for PIC&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;a href=&quot;http://www.mikroe.com/eng/products/view/9/mikrobasic-pro-for-pic/&quot;&gt;&lt;img src=&quot;http://www.mikroe.com/img/compilers/mikrobasic/pro/pic/default/mikrobasic-pro-thumb.gif&quot; alt=&quot;mikroBasic PRO for PIC&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Lucida Grande&#39;, &#39;Lucida Sans Unicode&#39;, Verdana, Arial, Helvetica, sans-serif; line-height: 24px; font-size: medium; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-style: initial; border-color: initial; border-style: initial; border-color: initial; outline-width: initial; outline-color: initial;&quot;&gt;&lt;u&gt;&lt;a href=&quot;http://www.mikroe.com/eng/products/view/10/mikropascal-pro-for-pic/&quot;&gt;&lt;img src=&quot;http://www.mikroe.com/img/compilers/mikropascal/pro/pic/default/mikropascal-pro-thumb.gif&quot; title=&quot;mikroPascal PRO for PIC&quot; alt=&quot;mikroPascal PRO for PIC&quot; style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-style: initial; border-color: initial; &quot; /&gt;&lt;/a&gt;&lt;/u&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;El compilador de estos lenguajes, toma nuestra fuente... este ejemplo enciende y apaga un led conectado al puerto RB0 en intervalos de 50 milisegundos:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;i&gt;...&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;#define led0 0b00000001&lt;/i&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;i&gt;void main() {&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;   TRISB=0;     //puerto B Salida&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;   PORTB = 0;   //todas las salidas en 0 lógico&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;   do {&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;         PORTB = led0;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;         Delay_ms(50);&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;         PORTB = led0;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;         Delay_ms(50);&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;   } while(1);&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;   &lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;}&lt;/i&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;No nos asustemos aún. En el próximo artículo explicaremos para que son los puertos y los tipos de puertos que hay, etc. Por lo pronto hagamos un acto de FE y entendamos que este programita de pocas líneas solo hace titilar un led en intervalos de 50 milisegundos.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Al ser compilado lo que obtendremos es un archivo de extensión .hex, con la siguiente información.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;i&gt;:0A00000005280000000000000028A1&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;:10000A00831686018312860101308600A330CC0054&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;:10001A005530CD00CD0B0F28CC0B0F2801308600B0&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;:10002A00A330CC005530CD00CD0B1928CC0B1928A4&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;:04003A0009281E284B&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;:02400E00FA3F77&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;:00000001FF&lt;/i&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Finalmente este es el archivo que vamos  utilizar para programar nuestro micro. Este archivo contiene registros en hexadecimal que traduce lo que programamos en el lenguaje que escogimos. Esto sucede para cualquier lenguaje, incluyendo al assembler.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Con que programamos el micro?... no con el código de alto nivel sino con el producto compilado el cual es este archivo .hex.  Existen programas especializados, que utilizan nuestro código compilado y permiten programar el micro, pero esto es harina de otro costal... o material de otro artículo, el cual prometo será pronto.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;De hecho, y es para otro artículo también, hay simuladores que permiten probar nuestro código compilado y verificar que el mismo se comporta adecuadamente. Puedo comentarles que uno de los mejores que he visto y en el cul me he divertido más es ISIS de Proteus.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;En este simulador no solo puedes armar el circuito virtual, sino cargar en el microprocesador escogido el código compilado y ejecutarlo. El simulador es tan bueno que permite crear los circuitos con los componentes virtuales y estos interactúan como si fuesen reales (ejemplo, leds, reles, servos, etc.)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;OK, pero no nos distraigamos del objetivo de este artículo, terminemos con este capítulo de lenguajes de programación para micros.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lo que hemos visto hasta el momento refiere a los lenguajes que nos permiten programar a los microprocesadores PIC, pero hay otros en el mercado. No me voy a extender mucho porque hay tanto que no tiene sentido. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Mi interés principal está en entender la tecnología y por lo que he revisado, he escogido dos tipos: PIC y ARDUINO-Like.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Ya veremos en otros artículos de que se trata y explicaremos cada uno en específico, por lo pronto entendamos que de la gran cantidad de tecnologías existentes en el mercado, he escogido 2 para seguir este viaje.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lo que si puedo decir en este punto es que Arduino o sus clones (y tendremos oportunidad de extendernos aquí) son mucho más amigables que los PIC, pero cada uno tiene sus encantos.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;ARDUINO es más amigable, más sencillo y con las mismas prestancias que los PIC, pero los PIC están muy difundidos en el mercado desde hace años, por lo que se consiguen muchísimos desarrollos para estos, lo cual los hace atractivos.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Ya seguiremos con los micros y cada vez más cercanos a proyectos prácticos que nos permitan verle el queso a la tostada.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Cheers!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Algunos conceptos (Wikipedia y otros)&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1) Assembler&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;El término ensamblador (del inglés assembler) se refiere a un tipo de programa informático que se encarga de traducir un fichero fuente escrito en un lenguaje ensamblador, a un fichero objeto que contiene código máquina, ejecutable directamente por la máquina para la que se ha generado. El propósito para el que se crearon este tipo de aplicaciones es la de facilitar la escritura de programas, ya que escribir directamente en código binario, que es el único código entendible por la computadora, es en la práctica imposible. La evolución de los lenguajes de programación a partir del lenguaje ensamblador originó también la evolución de este programa ensamblador hacia lo que se conoce como programa compilador.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;http://es.wikipedia.org/wiki/Assembler&quot;&gt;Fuente: Wikipedia&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;2) Hex files&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;Intel HEX es un formato de archivo para la programación de microcontroladores, EPROMs y otros circuitos integrados. Datando de los años 70[cita requerida], está entre los formatos más viejos con esta finalidad.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Consiste en un archivo de texto cuyas líneas contienen valores hexadecimales que codifican los datos, y su offset o dirección de memoria.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;fuente: &lt;a href=&quot;http://es.wikipedia.org/wiki/Intel_HEX&quot;&gt;Wikipedia&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adirgan.blogspot.com/feeds/5238444862636589028/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://adirgan.blogspot.com/2011/03/microcontroladores-parte-iv.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/5238444862636589028'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/5238444862636589028'/><link rel='alternate' type='text/html' href='http://adirgan.blogspot.com/2011/03/microcontroladores-parte-iv.html' title='Microcontroladores - Parte IV'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/15931139500048857110</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5192187322732553132.post-4324456748552763255</id><published>2011-01-23T16:21:00.000-08:00</published><updated>2011-01-23T17:28:36.027-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="design"/><category scheme="http://www.blogger.com/atom/ns#" term="dirgan"/><category scheme="http://www.blogger.com/atom/ns#" term="interactivity"/><category scheme="http://www.blogger.com/atom/ns#" term="Introduction"/><category scheme="http://www.blogger.com/atom/ns#" term="microcontroller"/><category scheme="http://www.blogger.com/atom/ns#" term="pic"/><category scheme="http://www.blogger.com/atom/ns#" term="pwm"/><category scheme="http://www.blogger.com/atom/ns#" term="robotic"/><category scheme="http://www.blogger.com/atom/ns#" term="teensy"/><title type='text'>Microcontroladores - parte III</title><content type='html'>Hoy seguiremos detallando los componentes de los microcontroladores, y el turno hoy es para la memoria y el subsistema de entrada/salida.&lt;br /&gt;&lt;br /&gt;Pero antes, revisemos otro de los videos relacionados con el macro mundo de los micros.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.youtube.com/watch?v=rSKRgasUEko&quot;&gt;NAO&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;Lo que podemos hacer con los micros es interminable... vean los features de comunicación que tiene este pequeño robot para interactuar con su entorno... Excelente. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Para llegar a hacer algo como NAO, no solo debemos conocer como diseñar aplicaciones para micros, sino como programarlos, como integrarlos la mundo real, como determinar su comportamiento, etcetera.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Debemos saber un poco de electrónica, de robótica, de mecánica, y mucha imaginación... y aunque este es un modelo comercial, la red está plagada de ejemplos de gente como nosotros que hace cosas interesantes, útiles e inútiles, que hacen de este mundo uno fascinante.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;En el árticulo anterior hablamos de la CPU de los microcontroladores. Para que este pueda operar debe tener acceso a datos, los cuales son albergados en lo que se conoce como memoria.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;MEMORIA&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Existen 2 tipos básicos de memoria: Memoria de Programa y Memoria de Datos. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;De Progama&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;En esta memoria se guardan las instrucciones de los programas que definen el comportamiento del micro. Esta puede ser de una sola escritura (ROM) o pueden ser volátiles, es decir, son reprogramables. Existen diferentes tipos de memoria volátil, las diferencias fundamentales están en los procedimientos de escritura y borrado de las mismas. Entre los tipos de memoria volátiles se encuentran la EPROM, EEPROM y la FLASH, esta última muy utilizada últimamente por sus prestancias, capacidad y confiabilidad, llegando a ofrecer hasta 1000 ciclos escritura-borrado.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;De Datos&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;La memoria de datos permite mantener la información con la que los programas trabajan. Esta memoria puede ser volátil como la memoria RAM (SRAM). Este tiene el inconveniente que si existe una caída de voltage, los datos se perderán. Hay aplicaciones que permiten este tipo de comportamiento, pero en el caso de aplicaciones que no lo permitan por su criticidad existen memorias no volátiles, como EEPROM la cual la traen disponible muchos micros. Estas memorias mantienen sus datos inclusive sin alimentación eléctrica.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;NOTA: La memoria tipo EEPROM y la tipo Flash pueden escribirse y borrarse eléctricamente, sin necesidad de sacar el circuito integrado del grabador.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;ENTRADA y SALIDA&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Un microcontrolador puede obtener input de su entorno, o sacar información al exterior a través de sus líneas de entrada y salida. Estas son las patas que se pueden ver en la siguiente imagen.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;meta equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;&lt;img src=&quot;http://www.lifia.info.unlp.edu.ar/es/difusion/20070705/foto_uno.png&quot; /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;A excepción de dos patas destinadas a recibir la alimentación, otras dos para el cristal de cuarzo (no todos los modelos requieren cristales externos), que regula la frecuencia de trabajo, y una más para reiniciar el micro, las patas restantes sirven para la comunicación con los periféricos externos que pudiera controlar.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;   Las líneas de E/S que se adaptan con los periféricos manejan información en paralelo y se&lt;/div&gt;&lt;div&gt;agrupan en grupos de ocho, y reciben el nombre de Puertas (Gates). Hay modelos con líneas que soportan la comunicación en serie; otros disponen de conjuntos de líneas que implementan&lt;/div&gt;&lt;div&gt;puertas de comunicación para diversos protocolos, como el I2oC, el USB, etc.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Estas patas o pines pueden configurarse como líneas de entrada o líneas de salida, es decir, estas pueden ser adaptadas a las necesidades del proyecto.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;E/S Analógicos y Digitales.&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Existen diferentes tipos de puertos. Los que son analógicos pueden aceptar diferentes voltages (generalmente entre 0V y 5V) en escalas decimales. Desde adentro del micro estos valores de voltaje pueden ser leídos desde una pin de entrada como un valor numérico (i.e. 0-1023).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Por ejemplo, un sensor de temperatura genera, de acuerdo a la temperatura a la cual se somete (Ambiental), un voltaje que si está conectado a un pin análogo, este podrá leerse como un valor  numérico. De acuerdo al fabricante este valor numérico se podrá convertir a grados celsius o farenheit, de acuerdo a la la escala que necesitemos.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Las líneas Digitales solo aceptan valores binarios. OV o cero lógico (FALSE) y 5V o 1 lógico (TRUE).  &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Ejemplo, una salida digital puede utilizarse para encender o apagar un led que esté conectado a un pin de salida digital.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Existe un tipo de salida especial llamado PWM (Pulse Width Modulation). Generalmente se usa para cambiar la resolución de la salida de un micro a valores más discretos en rangos grandes. Esto permite, por ejemplo, graduar la intensidad de un led como si usáramos un dimmer o para controlar un servo.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Otros RECURSOS&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Existen otros recursos en los procesadores que pueden ser útiles para hacerlos comportarse de una u otra forma de forma más rápida. Estos recursos pueden ser:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;a) Circuitos de reloj, encargados de generar los impulsos que sincronizan el funcionamiento de todo el sistema.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;b) Temporizadores, orientados a controlar tiempos.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;c) Perro Guardián («watchdog»), el cual permite generar una inicialización cuando el programa quede bloqueado eventualmente.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;d) Conversores AD y DA, para poder recibir y enviar señales analógicas.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;e) Comparadores analógicos, para verificar el valor de una señal analógica.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;f) Sistemas de protección ante fallos de alimentación.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Entrar en estos conceptos puede ser interesante, pero lo haré de aquí en adelante cuando sea requerido implementarlo para algún ejemplo o proyecto.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Algunos conceptos (Wikipedia y otros)&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1) &lt;a href=&quot;http://es.wikipedia.org/wiki/Modulaci%C3%B3n_por_ancho_de_pulsos&quot;&gt;PWM&lt;/a&gt;: La modulación por ancho de pulsos (también conocida como PWM, siglas en inglés de pulse-width modulation) de una señal o fuente de energía es una técnica en la que se modifica el ciclo de trabajo de una señal periódica (una senoidal o una cuadrada, por ejemplo), ya sea para transmitir información a través de un canal de comunicaciones o para controlar la cantidad de energía que se envía a una carga.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adirgan.blogspot.com/feeds/4324456748552763255/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://adirgan.blogspot.com/2011/01/microcontroladores-parte-iii.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/4324456748552763255'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5192187322732553132/posts/default/4324456748552763255'/><link rel='alternate' type='text/html' href='http://adirgan.blogspot.com/2011/01/microcontroladores-parte-iii.html' title='Microcontroladores - parte III'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/15931139500048857110</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>