Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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 |
--- 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);
}
}
