Сбор информации о погодных условиях

Dependencies:   RF24 USBDevice mbed

Committer:
pro100kot14
Date:
Thu Oct 22 20:31:06 2015 +0000
Revision:
2:ad2653bcf93f
Parent:
1:8766173d267f
Child:
3:346b49152f1e
Added the class of information processing with photoresist with the interpretation of it as light levels.; Added lighting classification as enum Illumination; Fixed bug in calculation of the temperature read from thermistor.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pro100kot14 0:1e03d2cd238f 1 #include "mbed.h"
pro100kot14 0:1e03d2cd238f 2 #include "USBSerial.h"
pro100kot14 0:1e03d2cd238f 3 #include "ThermometerTmp36.h"
pro100kot14 1:8766173d267f 4 #include "Thermistor.h"
pro100kot14 2:ad2653bcf93f 5 #include "Photoresistor.h"
pro100kot14 0:1e03d2cd238f 6
pro100kot14 0:1e03d2cd238f 7 USBSerial pc;
pro100kot14 1:8766173d267f 8 AnalogIn tmp36(A0);
pro100kot14 1:8766173d267f 9 AnalogIn thermist(A2);
pro100kot14 2:ad2653bcf93f 10 AnalogIn photoresist(A4);
pro100kot14 2:ad2653bcf93f 11 char lightLevels[][12]={
pro100kot14 2:ad2653bcf93f 12 "Dark",
pro100kot14 2:ad2653bcf93f 13 "Very cloudy",
pro100kot14 2:ad2653bcf93f 14 "Cloudy",
pro100kot14 2:ad2653bcf93f 15 "Clear",
pro100kot14 2:ad2653bcf93f 16 "Very sunny"
pro100kot14 2:ad2653bcf93f 17 };
pro100kot14 0:1e03d2cd238f 18 int main() {
pro100kot14 1:8766173d267f 19 ThermometerTmp36 termTmp36(tmp36);
pro100kot14 1:8766173d267f 20 Thermistor term503(thermist, 0.001995, 0.00007997, 0.0000003863);
pro100kot14 2:ad2653bcf93f 21 Photoresistor light(photoresist);
pro100kot14 1:8766173d267f 22 term503.setError(-5000);
pro100kot14 0:1e03d2cd238f 23 while(1) {
pro100kot14 2:ad2653bcf93f 24 pc.printf("TMP36: %f degC\tTermistor: %f degC\t%s\r\n", termTmp36.getTemperature(), term503.getTemperature(), lightLevels[light.getIllumination()]);
pro100kot14 0:1e03d2cd238f 25 wait(1);
pro100kot14 0:1e03d2cd238f 26 }
pro100kot14 0:1e03d2cd238f 27 }