![](/media/cache/group/200px-Rohm_logo_2009.png.50x50_q85.png)
Rohm ml8511 hello world application
Dependencies: mbed
Fork of BD1020HFV_Hello by
Revision 3:42bb7dfeffb2, committed 2016-09-20
- Comitter:
- MikkoZ
- Date:
- Tue Sep 20 11:06:00 2016 +0000
- Parent:
- 2:a4e87cfd1e0a
- Commit message:
- Refactored main program.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r a4e87cfd1e0a -r 42bb7dfeffb2 main.cpp --- a/main.cpp Tue Sep 13 07:45:54 2016 +0000 +++ b/main.cpp Tue Sep 20 11:06:00 2016 +0000 @@ -4,6 +4,16 @@ AnalogIn sensorout(A0); DigitalOut enablesensor(A1); +void ml8511_print_one_value(){ + float uvraw, uv; + #define MIN (0.300) + #define MAX (0.900) + #define UVONMAX 15 + uvraw = sensorout; + uv = ( (UVONMAX/(MAX-MIN)) * (uvraw - MIN) ); + pc.printf("UV Intensity %2.2fmW/cm^2 (raw[%2.3f])\r\n", uv, uvraw); + } + int main() { pc.printf("\n\r"); pc.printf("ML8511 UV sensor test program.\n\r"); @@ -13,13 +23,7 @@ wait_ms(1); while(1) { - float uvraw, uv; - #define MIN (0.300) - #define MAX (0.900) - #define UVONMAX 15 - uvraw = sensorout; - uv = ( (UVONMAX/(MAX-MIN)) * (uvraw - MIN) ); - pc.printf("UV Intensity %2.2fmW/cm^2 (raw[%2.3f])\r\n", uv, uvraw); + ml8511_print_one_value(); wait(0.4); } }