Rohm ml8511 hello world application

Dependencies:   mbed

Fork of BD1020HFV_Hello by Rohm

Committer:
MikkoZ
Date:
Tue Sep 13 07:45:54 2016 +0000
Revision:
2:a4e87cfd1e0a
Parent:
1:ba7e525074f9
Child:
3:42bb7dfeffb2
Rohm ml8511 hello world initial version.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MACRUM 0:ee7b9cc966d7 1 #include "mbed.h"
MACRUM 0:ee7b9cc966d7 2
MACRUM 0:ee7b9cc966d7 3 Serial pc(USBTX, USBRX);
MikkoZ 2:a4e87cfd1e0a 4 AnalogIn sensorout(A0);
MikkoZ 2:a4e87cfd1e0a 5 DigitalOut enablesensor(A1);
MACRUM 0:ee7b9cc966d7 6
MACRUM 0:ee7b9cc966d7 7 int main() {
MikkoZ 2:a4e87cfd1e0a 8 pc.printf("\n\r");
MikkoZ 2:a4e87cfd1e0a 9 pc.printf("ML8511 UV sensor test program.\n\r");
MikkoZ 2:a4e87cfd1e0a 10 pc.printf("Reported UV intensity values are rough approximates.\n\r");
MikkoZ 2:a4e87cfd1e0a 11 pc.printf("Please refer to specification page 4 for UV intensity characteristics.\n\r");
MikkoZ 2:a4e87cfd1e0a 12 enablesensor = 1;
MikkoZ 2:a4e87cfd1e0a 13 wait_ms(1);
MikkoZ 2:a4e87cfd1e0a 14
MACRUM 0:ee7b9cc966d7 15 while(1) {
MikkoZ 2:a4e87cfd1e0a 16 float uvraw, uv;
MikkoZ 2:a4e87cfd1e0a 17 #define MIN (0.300)
MikkoZ 2:a4e87cfd1e0a 18 #define MAX (0.900)
MikkoZ 2:a4e87cfd1e0a 19 #define UVONMAX 15
MikkoZ 2:a4e87cfd1e0a 20 uvraw = sensorout;
MikkoZ 2:a4e87cfd1e0a 21 uv = ( (UVONMAX/(MAX-MIN)) * (uvraw - MIN) );
MikkoZ 2:a4e87cfd1e0a 22 pc.printf("UV Intensity %2.2fmW/cm^2 (raw[%2.3f])\r\n", uv, uvraw);
MACRUM 0:ee7b9cc966d7 23 wait(0.4);
MACRUM 0:ee7b9cc966d7 24 }
MACRUM 0:ee7b9cc966d7 25 }