Elektronikprojekt Grupp 13
/
TestMic
TestMic
mictest.cpp@0:ff359bd0a096, 2017-04-10 (annotated)
- Committer:
- elt14lpo
- Date:
- Mon Apr 10 11:36:37 2017 +0000
- Revision:
- 0:ff359bd0a096
- Child:
- 1:b7c5a1dba0c3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
elt14lpo | 0:ff359bd0a096 | 1 | #include<stdio.h> |
elt14lpo | 0:ff359bd0a096 | 2 | #include<AnalogIn.h> |
elt14lpo | 0:ff359bd0a096 | 3 | #include<mbed.h> |
elt14lpo | 0:ff359bd0a096 | 4 | #include<DHT.h> |
elt14lpo | 0:ff359bd0a096 | 5 | |
elt14lpo | 0:ff359bd0a096 | 6 | AnalogIn mic1(A0); |
elt14lpo | 0:ff359bd0a096 | 7 | AnalogIn mic2(A1); |
elt14lpo | 0:ff359bd0a096 | 8 | AnalogIn mic3(A2); |
elt14lpo | 0:ff359bd0a096 | 9 | DHT sensor(A3, DHT11); |
elt14lpo | 0:ff359bd0a096 | 10 | |
elt14lpo | 0:ff359bd0a096 | 11 | const int n = 100; |
elt14lpo | 0:ff359bd0a096 | 12 | int m1[n]; |
elt14lpo | 0:ff359bd0a096 | 13 | int m2[n]; |
elt14lpo | 0:ff359bd0a096 | 14 | int m3[n]; |
elt14lpo | 0:ff359bd0a096 | 15 | int data; |
elt14lpo | 0:ff359bd0a096 | 16 | |
elt14lpo | 0:ff359bd0a096 | 17 | int main(){ |
elt14lpo | 0:ff359bd0a096 | 18 | for(int i = 0; i<n; ++i){ |
elt14lpo | 0:ff359bd0a096 | 19 | float f1 = 10*mic1.read(); |
elt14lpo | 0:ff359bd0a096 | 20 | float f2 = 10*mic2.read(); |
elt14lpo | 0:ff359bd0a096 | 21 | float f3 = 10*mic3.read(); |
elt14lpo | 0:ff359bd0a096 | 22 | printf("Mic 1: "); |
elt14lpo | 0:ff359bd0a096 | 23 | printf("%10.6f",f1); |
elt14lpo | 0:ff359bd0a096 | 24 | printf("\t Mic 2:"); |
elt14lpo | 0:ff359bd0a096 | 25 | printf("%10.6f", f2); |
elt14lpo | 0:ff359bd0a096 | 26 | printf("\t Mic 3:"); |
elt14lpo | 0:ff359bd0a096 | 27 | printf("%10.6f", f3); |
elt14lpo | 0:ff359bd0a096 | 28 | printf("\n"); |
elt14lpo | 0:ff359bd0a096 | 29 | //wait(0.1); |
elt14lpo | 0:ff359bd0a096 | 30 | m1[i]=f1; |
elt14lpo | 0:ff359bd0a096 | 31 | m2[i]=f2; |
elt14lpo | 0:ff359bd0a096 | 32 | m2[i]=f3; |
elt14lpo | 0:ff359bd0a096 | 33 | |
elt14lpo | 0:ff359bd0a096 | 34 | data = sensor.readData(); |
elt14lpo | 0:ff359bd0a096 | 35 | if (data == 0){ |
elt14lpo | 0:ff359bd0a096 | 36 | printf("Temp: %4.2f C",sensor.ReadTemperature(CELCIUS)); |
elt14lpo | 0:ff359bd0a096 | 37 | printf("Hum: %4.2f",sensor.ReadHumidity()); |
elt14lpo | 0:ff359bd0a096 | 38 | } |
elt14lpo | 0:ff359bd0a096 | 39 | printf("\n"); |
elt14lpo | 0:ff359bd0a096 | 40 | |
elt14lpo | 0:ff359bd0a096 | 41 | } |
elt14lpo | 0:ff359bd0a096 | 42 | } |