Sunghun Kim
/
analog_in_temperature
1
Diff: main.cpp
- Revision:
- 0:d039f36b5a64
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Mar 07 12:04:37 2021 +0000 @@ -0,0 +1,25 @@ +#include "mbed.h" + +// Initialize a pins to perform analog input and digital output fucntions +AnalogIn temperature1(A0); +AnalogIn humadity1(A1); +AnalogIn temperature2(A2); +AnalogIn humadity2(A3); +AnalogIn co2(A4); + +int main(void) +{ + while (1) { + + // 10v analog output + printf("t1: %3.1f\t", temperature1.read() * 44.0f); + printf("h1: %3.1f\t", humadity1.read() * 90.0f); + + // 5v analog output + printf("t2: %3.1f\t", temperature2.read() * 48.0f); + printf("h2: %3.1f\t", humadity2.read() * 115.0f); + + printf("co2: %3.1f\n", co2.read() * 100.0f); + wait(0.2f); + } +} \ No newline at end of file