HEPTA-Sat Training 2022 / Mbed 2 deprecated Lab7-sample_light-sensor

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 Serial pc(USBTX, USBRX);
00004 DigitalOut led0(LED1), led25(LED2), led50(LED3), led75(LED4);
00005 
00006 AnalogIn temt6000(p15);
00007 // temt6000 breakout: VCC(to VOUT=3.3V), GND(to GND), SIG(to p15) 
00008 
00009 int main()
00010 {
00011   for(;;)
00012   {
00013     float x = temt6000;
00014     
00015     // four LEDs meaning "light level" (1 to 4):
00016     led0 = 1;
00017     led25 = led50 = led75 = 0;
00018     if(x>0.25) led25 = 1;
00019     if(x>0.50) led50 = 1;
00020     if(x>0.75) led75 = 1;
00021     
00022     printf("%f\r\n", x);
00023     wait(0.50);
00024   }
00025 }