measuring the salinity
Dependencies: LinearAnalogSensors mbed
Fork of mbed_measuring_temperature by
Diff: main.cpp
- Revision:
- 2:1aab63839dba
- Parent:
- 1:6476db5e52e8
- Child:
- 3:5baf5ad00c1c
diff -r 6476db5e52e8 -r 1aab63839dba main.cpp --- a/main.cpp Wed Jun 01 11:29:31 2016 +0000 +++ b/main.cpp Thu Jun 02 12:10:27 2016 +0000 @@ -1,23 +1,46 @@ #include "mbed.h" +//#include <LinearTemp.h> + Serial pc(USBTX, USBRX); DigitalOut myled1(LED1), myled2(LED2); -AnalogIn LM61(p15); - +AnalogIn pin_1(p16); +//LinearTemp mysensor(p15, 0.0050354, -273.15); + char program_name[128] = "Serial IO"; int main() { - pc.printf("run: %s\n", program_name); + /*pc.printf("run: %s\n", program_name); float temp, tempC, tempF; while(1) { - temp = LM61; - tempC = ((temp*3.3)-0.600)*100.0; + //temp = LM61; + tempC = ((pin_1.read()*3.3)-0.600)*100.0; + printf("%5.4F\n",(pin_1.read()*3.3)); //convert to degrees F tempF = (9.0*tempC)/5.0 + 32.0; //print current temp - printf("%5.2F : %5.2F C %5.2F F \n\r", temp, tempC, tempF); + printf("%5.4F : %5.2F C %5.2F F\n\r", pin_1.read(), tempC, tempF); wait(2); + }*/ + /*while(1) { + // Light LED if filtered temperature is greater than 45 degrees Celsius + mysensor.readTemp(); + printf("%5.4F : (%f) \n\r", pin_1.read(), mysensor.getTemp()); + if (mysensor.getTemp() > 10) myled1 = 1; + else myled1 = 0; + wait(2); + }*/ + + + while(1){ + wait(2); + float f = pin_1.read(); + float vin = f * 3.3; + float divider = (float)5/ (float)3; + float vout = vin * divider; + float salt = 16.3 * vout; + pc.printf("vin: %f, vin2: %f, salt: %f \n\r", vin, vout, salt); } }