Sensor de Luz con Arduino y Relays

Sensor de Luz con Arduino y Relays

Con ayuda de nuestro sensor de luz lograremos desarrollar un programa en Arduino que permitirá controlar un relay de acuerdo a la variación de luz detectada en el ambiente.

Requisitos

Software Arduino
Módulo Sensor de Luz
Módulo Relay de 5v

Preparando el programa

Para comenzar abrimos nuestro IDE Arduino y necesitaremos reconocer los pines que vamos a utilizar en mi caso usare para el sensor de luz el pin A0 y para el módulo relay el pin 2 digital.

Programando arduino sensor luz relay

En la función loop asignamos la lectura del pin del sensor de luz hacia la variable "sensorvalor" donde se almacenará el valor obtenido dependiendo de la luz del medio en que se encuentra.

Luego haremos un condicional if para comparar el valor obtenido del sensor de luz, este valor debe calibrarse según el lugar donde se encuentre el sensor. En mi caso lo he configurado con el valor de 440.

En caso de que se cumpla la condición de que el sensor detecte el valor de luz mayor a 440 el relay se apagará, en este caso indique el valor al ledpin2 de HIGH, esto es porque mi módulo relay funciona a la inversa. Cuando se le indica el valor HIGH se apaga y cuando se indica el valor LOW se enciende. Con esto hago que en una zona donde no haya luz el sensor automáticamente active el relay y este accione el switch para un foco dando luz al ambiente, en caso contrario se apaga.

Publicar un comentario

Guardar mi nombre, correo electrónico y sitio web en este navegador la próxima vez que comente

5 Comentarios

  1. China comparatively has near 80% penetration in urban cities for air conditioners and yet it sits at close to 8% in very rural areas. There are lots of other tools and tricks for having your site on to Google, but if you do these simple things, yyou should have built a good foundation where it is possible to grow. But you're going to have to successfully understand thesee differences. http://imailsupport.com/contact-gmail/

  2. Also look for the online communities your target users visit frequently. If you've done these things but sstill find you have not been indexed, check your file to uccessfully usuallly aare not blocking the engines. Buut you happen to be going to have to enmsure that you understand these differences. http://imailsupport.com/contact-gmail/

  3. These are in fact fantastic ideas in concerning blogging. You have touched some fastidious points here. Any way keep up wrinting. I have been browsing online more than three hours nowadays, yet I never found any fascinating article like yours. It’s beautiful value sufficient for me. In my view, if all website owners and bloggers made just right content material as you did, the internet will probably be much more useful than ever before. Thank you for the auspicious writeup. It in fact was a amusement account it. Look advanced to more added agreeable from you! By the way, how could we communicate? http://cars.com

  4. Greetings from California! I'm bored to tears at work so I decided to check out your website on my iphone during lunch break. I love the knowledge you provide here and can't wait to take a look when I get home. I'm shocked at how quick your blog loaded on my mobile .. I'm not even using WIFI, just 3G .. Anyhow, awesome site! https://uricasino114.com

  5. I have been exploring for a little for any high-quality articles or blog posts in this sort of area . Exploring in Yahoo I ultimately stumbled upon this site. Reading this information So i’m glad to exhibit that I have a very just right uncanny feeling I came upon exactly what I needed. I most unquestionably will make sure to do not disregard this site and give it a look on a continuing basis.