Reply to topic  [ 1 post ] 
Photosensitive Resistance Sensor Module (HCMODU0109) 
Author Message
Site Admin

Joined: Sun Aug 05, 2012 4:02 pm
Posts: 629
Post Photosensitive Resistance Sensor Module (HCMODU0109)
Image




This is a simple photosensitive resistance sensor module. The sensor has a digital output that will go high if light is detected above a threshold set by the modules potentiometer. Additionally there is also an analogue output which will vary between 0 and 5V depending on the amount of light hitting the sensor.



Pinout

Image




Example Arduino Sketch

Code:
/* FILE:    HCMODU0109_PhotoResistor_Module_Example
   DATE:    31/08/2016
   VERSION: 0.1

This is a simple example of how to use the Hobby Components photoresistor light detection
module (HCMODU0109).

You may copy, alter and reuse this code in any way you like, but please leave
reference to HobbyComponents.com in your comments if you redistribute this code.
This software may not be used directly for the purpose of selling products that
directly compete with Hobby Components Ltd's own range of products.

THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, WHETHER
EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK OF NEGLIGENCE.
HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES,
INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY
REASON WHATSOEVER.

*/   
                                 
/* Select the input pin for the modules digital output. */
#define PHOTO_DETC_DIO 2     
                                 


/* Initialise serial and DIO */
void setup()
{
  /* Setup the serial port for displaying the status of the sensor */
  Serial.begin(9600);
 
  /* Configure the DIO pin the sensors digital output will be connected to */
  pinMode(PHOTO_DETC_DIO, INPUT);
}


/* Main program loop */
void loop()
{
 
  /* Read the status of the sensors digital output and if it is high
     then send an alert to the UART */
  if (digitalRead(PHOTO_DETC_DIO))
  {
    Serial.println("NIGHT TIME!!");
  }else
  {
    Serial.println("DAY TIME!!");
  }

  delay(500);
   
}





Disclaimer: Libraries, example code, and diagrams are provided as an additional free service by Hobby Components and are not sold as part of this product. We do no provide any guarantees or warranties as to their accuracy or fitness for purpose.

Descriptions and diagrams on this page are copyright Hobby Components Ltd and may not be reproduced without permission.


Wed Aug 31, 2016 12:49 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Thank you to phpBB.com & phpBB.ro.
Design created by Florea Cosmin Ionut.
© 2011 All contents of this site are © Hobby Components LTD