Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:94c8543dd5e9, committed 2020-12-01
- Comitter:
- mkistler
- Date:
- Tue Dec 01 13:57:08 2020 +0000
- Commit message:
- SCI_SENSOR
Changed in this revision
SCI_SENSOR.cpp | Show annotated file Show diff for this revision Revisions of this file |
SCI_SENSOR.h | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SCI_SENSOR.cpp Tue Dec 01 13:57:08 2020 +0000 @@ -0,0 +1,33 @@ +#include "SCI_SENSOR.h" + +LM19::LM19(PinName in1): _in1(in1) +{ + c1 = -1481.96; + c2 = 2.1962*1000000.000; + c3 = 1.8636; + c4 = 3.88/1000000.000; +} + +float LM19::temp() +{ + float volt=_in1.read()*3.3; + float T=c1+sqrt(c2 + (c3-volt)/c4); + return T; +} + +PhotoCell::PhotoCell(PinName in1): _in1(in1) +{ + Rs = 10000.00; +} + +float PhotoCell::light() +{ + float vlight=_in1.read()*3.3; + //convert voltage into resistance + //convert resistance into light + float A =-2; + float B = 3.8; + float R = (3.3*Rs/vlight - Rs)/1000.00; + float lux = pow(10, A*log10(R)+B); + return lux; +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SCI_SENSOR.h Tue Dec 01 13:57:08 2020 +0000 @@ -0,0 +1,31 @@ +#ifndef sci_sensor_H +#define sci_sensor_H + +#include "mbed.h" + +class LM19 +{ + +public: + LM19(PinName in1); //initialization function + float c1, c2, c3, c4; + float temp();//temp comp. +private: + AnalogIn _in1; + +}; + +class PhotoCell +{ + +public: + PhotoCell(PinName in1); + float Rs; + float light(); + +private: + AnalogIn _in1; + +}; + +#endif \ No newline at end of file