christian l.
/
lightdetector
Light detector with simple LDR and LCD display,there exist no calibration
Revision 0:f1db4613080a, committed 2011-02-15
- Comitter:
- christian
- Date:
- Tue Feb 15 21:24:10 2011 +0000
- Commit message:
Changed in this revision
diff -r 000000000000 -r f1db4613080a TextLCD.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Tue Feb 15 21:24:10 2011 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/TextLCD/#44f34c09bd37
diff -r 000000000000 -r f1db4613080a main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Feb 15 21:24:10 2011 +0000 @@ -0,0 +1,23 @@ +#include "mbed.h" +#include "TextLCD.h" + +TextLCD lcd(p10, p12, p15, p16, p29, p30); // rs, e, d0-d3 + +AnalogIn Vin(p20); // 3.3V Vout - 4K7 resistor - pin20 - LDR -100 ohm resistor - GND + + main() + { + while(1) { + int x = 0; + + for (int i=0;i<=100;i++){ + x = x + 1000*(1-Vin.read()); //build average from 100 values + wait (0.01); + } + x=x/100; + lcd.cls(); + lcd.printf("light intensity\n"); + lcd.printf("%d\n",x); //value x is only relative,maybe anybody could calibrate it ? + + } +}
diff -r 000000000000 -r f1db4613080a mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Feb 15 21:24:10 2011 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912