Sets up LCD and prints sensor data value of TSL2561 light sensor to LCD
Dependencies: C12832 Sht31 TSL2561
Fork of mbed-cloud-connect-sensor-air-quality by
main.cpp
00001 #include "mbed.h" 00002 #include "C12832.h" 00003 #include "TSL2561.h" 00004 00005 /* Sets up LCD and prints sensor data value of Indoor Air Quality sensor to LCD */ 00006 00007 C12832 lcd(PE_14, PE_12, PD_12, PD_11, PE_9); //LCD: MOSI, SCK, RESET, A0, nCS 00008 TSL2561 tsl2561(PF_0, PF_1, TSL2561_ADDR_HIGH); //LIGHT SENSOR: I2C_SDA, I2C_SCL 00009 00010 int main() 00011 { 00012 tsl2561.begin(); 00013 tsl2561.setGain(TSL2561_GAIN_0X); 00014 tsl2561.setTiming(TSL2561_INTEGRATIONTIME_402MS); 00015 00016 while(1) { 00017 int x = tsl2561.getLuminosity(TSL2561_VISIBLE); 00018 int z = tsl2561.getLuminosity(TSL2561_INFRARED); 00019 00020 lcd.cls(); 00021 lcd.locate(0,3); 00022 lcd.printf("[LIGHT]"); 00023 lcd.locate(0,14); 00024 lcd.printf("VIS: %d, INFR: %d ",x, z); 00025 wait(1); // Print to LCD values 00026 } 00027 }
Generated on Sun Jul 17 2022 14:30:12 by 1.7.2