Mark Schwarzer / Mbed 2 deprecated Project_OCE360

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SCI_SENSOR.cpp Source File

SCI_SENSOR.cpp

00001 #include "SCI_SENSOR.h"
00002  
00003 LM19::LM19(PinName in1): _in1(in1)
00004 {
00005     c1 = -1481.96;
00006     c2 = 2.1962*1000000.000;
00007     c3 = 1.8636;
00008     c4 = 3.88/1000000.000;
00009 }
00010  
00011 float LM19::temp()
00012 {
00013     float volt=_in1.read()*3.3;
00014     float T=c1+sqrt(c2 + (c3-volt)/c4);
00015     return T;
00016 }
00017  
00018 PhotoCell::PhotoCell(PinName in1): _in1(in1)
00019 {
00020     Rs = 10000.00;
00021 }
00022  
00023 float PhotoCell::light()
00024 {
00025     float vlight=_in1.read()*3.3;
00026     //convert voltage into resistance
00027     //convert resistance into light
00028     float A =-2;
00029     float B = 3.8;
00030     float R = (3.3*Rs/vlight - Rs)/1000.00;
00031     float lux = pow(10, A*log10(R)+B);
00032     return lux;
00033 }