The aim of this guide to show how to read the Light Dependent Resistor (LDR) and to set a Threshold to show when it is Dark or Light.

The code has been write as a class, the class is called “CYD_LDR.h”. So first let and start off by looking at the code we need to add to our program:

#include “CYDLDR.h” – this will includes the LDR class code in our program

CYD_LDR LDR; – Create a Object for the LDR

LDR.set_isDarkTreshold(value); – Set the is Dark Threshold to a value

LDR.get_LDR(); – Returns the value of the LDR

LDR.get_isDark(); – Return a boolean value whether is Dark ( True = Dark, False = Light)

Demo code and copy of the class can be download here

No responses yet

Leave a Reply

Your email address will not be published. Required fields are marked *