Photosensitive Resistance Sensor Module (HCMODU0109)

Modules for various types of sensors including accelerometers. gyro's, IR motion, etc
Post Reply
admin
Site Admin
Posts: 725
Joined: Sun Aug 05, 2012 4:02 pm

Photosensitive Resistance Sensor Module (HCMODU0109)

Post by admin » Wed Aug 31, 2016 12:49 pm

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: Select all

/* 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.

Post Reply