LaMP / Mbed 2 deprecated lightSense

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 AnalogIn ai_uva(A1);
00004 AnalogIn ai_uvb(A2);
00005 AnalogIn ai_pyrLL(A3);
00006 AnalogIn ai_pyrHL(A0);
00007 AnalogIn ai_temp(A4);
00008 
00009 
00010 DigitalOut led(LED1);
00011 
00012 int main()
00013 {
00014     unsigned short uva;         // UVA sensor (16-bit ADC code)
00015     unsigned short uvb;         // UVB sensor (16-bit ADC code)
00016     unsigned short pyrLL;       // pyranometer sensor for low lighting conditions (16-bit ADC code)
00017     unsigned short pyrHL;       // pyranometer sensor for high lighting conditions (16-bit ADC code)
00018     unsigned short temp;        // 10K NTC sensor (16-bit ADC code)
00019     
00020     printf("\n# LightSense - David Picard, LaMP, 2019\n");
00021     printf("# uint16 : 0..65535\n");
00022     printf("# UVA\tUVB\tpyr LL\tpyr HL\tTemp\n");
00023 
00024     while(1)
00025     {
00026         uva = ai_uva.read_u16();
00027         uvb = ai_uvb.read_u16();
00028         pyrLL = ai_pyrLL.read_u16();
00029         pyrHL = ai_pyrHL.read_u16();
00030         temp = ai_temp.read_u16();
00031         
00032         printf("%5d\t%5d\t%5d\t%5d\t%5d\n", uva, uvb, pyrLL, pyrHL, temp);   // print measurements
00033         
00034         // Blink LED with at a 1Hz frequency :
00035         led = !led;     // toggle LED
00036         wait(0.5);      // wait for 0.5s
00037         led = !led;     // toggle LED
00038         wait(0.5);      // wait for 0.5s
00039     }
00040 }