![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Diff: main.cpp
- Revision:
- 0:dba2bcefd284
- Child:
- 1:bdb889fd3bef
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Aug 24 23:11:45 2011 +0000 @@ -0,0 +1,34 @@ +#include "mbed.h" + +DigitalOut myled(LED1); + +AnalogIn hum(p20); +AnalogIn ref(p19); + +float av[5] = {0,0,0,0,0}; + +int main() { + while(1) { + + float h = hum.read(); + float r = ref.read(); + float v = 5.0*h/r; + + av[0] = av[1]; + av[1] = av[2]; + av[2] = av[3]; + av[3] = av[4]; + av[4] = v; + + float a = (av[0]+av[1]+av[2]+av[3]+av[4])/5.0; + + float m = (a-0.8)/3.0*100.0; + + printf("h=%1.2f r=%1.2f %1.2f %1.2f %3.1f\n\r", h, r, v, a, m ); + + myled = 1; + wait(0.2); + myled = 0; + wait(0.8); + } +}