![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
measuring the salinity
Dependencies: LinearAnalogSensors mbed
Fork of mbed_measuring_temperature by
main.cpp@1:6476db5e52e8, 2016-06-01 (annotated)
- Committer:
- mariosimaremare
- Date:
- Wed Jun 01 11:29:31 2016 +0000
- Revision:
- 1:6476db5e52e8
- Parent:
- 0:da915495c7fc
- Child:
- 2:1aab63839dba
Measuring temperature using sensor.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ekasinambela | 0:da915495c7fc | 1 | #include "mbed.h" |
ekasinambela | 0:da915495c7fc | 2 | |
ekasinambela | 0:da915495c7fc | 3 | Serial pc(USBTX, USBRX); |
ekasinambela | 0:da915495c7fc | 4 | DigitalOut myled1(LED1), myled2(LED2); |
mariosimaremare | 1:6476db5e52e8 | 5 | AnalogIn LM61(p15); |
ekasinambela | 0:da915495c7fc | 6 | |
mariosimaremare | 1:6476db5e52e8 | 7 | char program_name[128] = "Serial IO"; |
mariosimaremare | 1:6476db5e52e8 | 8 | |
mariosimaremare | 1:6476db5e52e8 | 9 | int main() |
mariosimaremare | 1:6476db5e52e8 | 10 | { |
mariosimaremare | 1:6476db5e52e8 | 11 | pc.printf("run: %s\n", program_name); |
mariosimaremare | 1:6476db5e52e8 | 12 | float temp, tempC, tempF; |
ekasinambela | 0:da915495c7fc | 13 | while(1) { |
mariosimaremare | 1:6476db5e52e8 | 14 | temp = LM61; |
mariosimaremare | 1:6476db5e52e8 | 15 | tempC = ((temp*3.3)-0.600)*100.0; |
mariosimaremare | 1:6476db5e52e8 | 16 | //convert to degrees F |
mariosimaremare | 1:6476db5e52e8 | 17 | tempF = (9.0*tempC)/5.0 + 32.0; |
mariosimaremare | 1:6476db5e52e8 | 18 | //print current temp |
mariosimaremare | 1:6476db5e52e8 | 19 | printf("%5.2F : %5.2F C %5.2F F \n\r", temp, tempC, tempF); |
mariosimaremare | 1:6476db5e52e8 | 20 | wait(2); |
mariosimaremare | 1:6476db5e52e8 | 21 | |
ekasinambela | 0:da915495c7fc | 22 | } |
ekasinambela | 0:da915495c7fc | 23 | } |