christian l.
/
lightdetector
Light detector with simple LDR and LCD display,there exist no calibration
main.cpp
- Committer:
- christian
- Date:
- 2011-02-15
- Revision:
- 0:f1db4613080a
File content as of revision 0:f1db4613080a:
#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 ? } }