darkness activated switch

Dependencies:   mbed

main.cpp

Committer:
faif
Date:
2012-02-11
Revision:
0:aa10f42a839d
Child:
1:8cf180275a19

File content as of revision 0:aa10f42a839d:

#include "mbed.h"
#include "main.h"

static const float threshOff = 0.5;      // when to turn the led on
static const float threshOn = 0.4;     // when to turn the led off

int main () 
{
    float ldr_value;
    while (true) 
    {
        ldr_value = myldr;
        if (ldr_value > threshOff)
        {
            myled = LedOff;
        }
        if (ldr_value < threshOn)
        {
            myled = LedOn;
        }
    }
}