Dependencies: mbed-STM32F103C8T6 mbed
main.cpp@0:7c21544e5cd3, 2018-06-08 (annotated)
- Committer:
- AbiOne
- Date:
- Fri Jun 08 15:55:53 2018 +0000
- Revision:
- 0:7c21544e5cd3
- Child:
- 1:278b6f18d227
1.0.1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AbiOne | 0:7c21544e5cd3 | 1 | #include "mbed.h" |
AbiOne | 0:7c21544e5cd3 | 2 | #include "stm32f103c8t6.h" |
AbiOne | 0:7c21544e5cd3 | 3 | //------------------------------------ |
AbiOne | 0:7c21544e5cd3 | 4 | // Hyperterminal configuration |
AbiOne | 0:7c21544e5cd3 | 5 | // 9600 bauds, 8-bit data, no parity |
AbiOne | 0:7c21544e5cd3 | 6 | //------------------------------------ |
AbiOne | 0:7c21544e5cd3 | 7 | |
AbiOne | 0:7c21544e5cd3 | 8 | Serial pc(SERIAL_TX, SERIAL_RX); |
AbiOne | 0:7c21544e5cd3 | 9 | |
AbiOne | 0:7c21544e5cd3 | 10 | DigitalOut myled(LED1); |
AbiOne | 0:7c21544e5cd3 | 11 | |
AbiOne | 0:7c21544e5cd3 | 12 | int main() |
AbiOne | 0:7c21544e5cd3 | 13 | { |
AbiOne | 0:7c21544e5cd3 | 14 | float meas; |
AbiOne | 0:7c21544e5cd3 | 15 | float very_hum_value; |
AbiOne | 0:7c21544e5cd3 | 16 | float soil_hum_perc; |
AbiOne | 0:7c21544e5cd3 | 17 | |
AbiOne | 0:7c21544e5cd3 | 18 | |
AbiOne | 0:7c21544e5cd3 | 19 | AnalogIn analog_value(A0); |
AbiOne | 0:7c21544e5cd3 | 20 | |
AbiOne | 0:7c21544e5cd3 | 21 | |
AbiOne | 0:7c21544e5cd3 | 22 | while(1) { |
AbiOne | 0:7c21544e5cd3 | 23 | wait(1); |
AbiOne | 0:7c21544e5cd3 | 24 | meas = analog_value.read(); |
AbiOne | 0:7c21544e5cd3 | 25 | |
AbiOne | 0:7c21544e5cd3 | 26 | soil_hum_perc = (meas - very_hum_value)/(1 - very_hum_value) * 100; // perevod v % |
AbiOne | 0:7c21544e5cd3 | 27 | pc.printf("Soil_Humidity: %f \%\n", meas); |
AbiOne | 0:7c21544e5cd3 | 28 | myled = !myled; |
AbiOne | 0:7c21544e5cd3 | 29 | } |
AbiOne | 0:7c21544e5cd3 | 30 | } |