w mx / Mbed 2 deprecated sensors

Dependencies:   mbed

Fork of sensors by BieWang

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers example.cpp Source File

example.cpp

00001 #include "sensors.h"
00002 #include "mbed.h"
00003 
00004 Serial usb2pc(PA_2, PA_3, 9600);  
00005 DigitalOut myled(PC_13);
00006 
00007 int main()
00008 {
00009 
00010     
00011     usb2pc.printf("starting\r\n");
00012     sr501 x(PB_1);
00013     BH1750 y(PB_7,PB_6);
00014     
00015     while(1)
00016     {
00017         /*
00018         if(x.operator ==(true))
00019         {
00020             usb2pc.printf("get\r\n");
00021             while(x.read()){usb2pc.printf("aaaaaaaaaaaaa\r\n");wait(0.1);myled=1;}
00022             x.reset();
00023         }
00024         
00025         else
00026         {
00027             usb2pc.printf("no\r\n");
00028         }
00029         wait(0.1);
00030         */
00031         
00032         float light=y.getlightdata();
00033         usb2pc.printf("Light intensity: %.4f Lux\r\n",light);
00034     }
00035 }