Brunno Oliveira / light_sensor
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "Si1133.h "
00003 
00004 //I2C i2c (p13, p15);
00005 //Create an Si1133 object
00006 Si1133 sensor(P0_13, P0_15);
00007 //Serial pc(p25, p26);
00008 
00009 int main()
00010 {
00011     
00012    //Try to open the Si1133
00013     if (sensor.open()) {
00014         printf("Device detected!\n");
00015         while (1) {
00016             //Print the current light level
00017             printf("Lux = %.3f\n", (float)sensor.get_light_level());
00018             //Print the current UV index
00019             printf("UV index = %.3f\n", (float)sensor.get_uv_index());
00020             //Sleep for 0.5 seconds
00021             wait(0.5);
00022         }
00023     } else {
00024         error("Device not detected!\n");
00025     }
00026 }