Rohm ml8511 hello world application

Dependencies:   mbed

Fork of BD1020HFV_Hello by Rohm

Revision:
2:a4e87cfd1e0a
Parent:
1:ba7e525074f9
Child:
3:42bb7dfeffb2
--- a/main.cpp	Thu Sep 08 11:13:51 2016 +0000
+++ b/main.cpp	Tue Sep 13 07:45:54 2016 +0000
@@ -1,14 +1,25 @@
 #include "mbed.h"
 
 Serial pc(USBTX, USBRX);
-AnalogIn sensor(A2);
+AnalogIn sensorout(A0);
+DigitalOut enablesensor(A1);
 
 int main() {
-    float temparature;
-    pc.printf("\nBD1020HFV Temperature sensor test program.\n");
+    pc.printf("\n\r");
+    pc.printf("ML8511 UV sensor test program.\n\r");
+    pc.printf("Reported UV intensity values are rough approximates.\n\r");
+    pc.printf("Please refer to specification page 4 for UV intensity characteristics.\n\r");
+    enablesensor = 1;
+    wait_ms(1);
+    
     while(1) {
-        temparature = -(1000 * (sensor * 3.3f) - 1546) / 8.2;
-        pc.printf("Temperature=%5.3f\r\n", temparature);
+        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);
         wait(0.4);
     }
 }