![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
main.cpp
- Committer:
- gbeardall
- Date:
- 2011-08-24
- Revision:
- 0:dba2bcefd284
- Child:
- 1:bdb889fd3bef
File content as of revision 0:dba2bcefd284:
#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); } }