fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include "TSL2561.h"
  4. #include <string>
  5. #include <iostream>
  6. #include <sstream>
  7. #include <unistd.h>
  8.  
  9. int getLux()
  10. {
  11. std::string iLux, iIR, returnS;
  12. uint16_t broadband, ir = 0;
  13. uint32_t lux=0;
  14.  
  15. //initialize the sensor and take a reading
  16. TSL2561 light1 = TSL2561_INIT(1, TSL2561_ADDR_FLOAT);
  17. TSL2561_OPEN(&light1);
  18. TSL2561_SETGAIN(&light1, TSL2561_GAIN_1X);
  19. TSL2561_SETINTEGRATIONTIME(&light1, TSL2561_INTEGRATIONTIME_402MS);
  20. TSL2561_SENSELIGHT(&light1, &broadband, &ir, &lux, 1);
  21.  
  22. return lux;
  23. }
  24.  
  25. int getIR()
  26. {
  27. std::string iLux, iIR, returnS;
  28. uint16_t broadband, ir = 0;
  29. uint32_t lux=0;
  30.  
  31. //initialize the sensor and take a reading
  32. TSL2561 light1 = TSL2561_INIT(1, TSL2561_ADDR_FLOAT);
  33. TSL2561_OPEN(&light1);
  34. TSL2561_SETGAIN(&light1, TSL2561_GAIN_1X) ;
  35. TSL2561_SETINTEGRATIONTIME(&light1, TSL2561_INTEGRATIONTIME_402MS);
  36. TSL2561_SENSELIGHT(&light1, &broadband, &ir, &lux, 1);
  37.  
  38. return ir;
  39. }
  40.  
  41. int main()
  42. {
  43. while(1)
  44. {
  45. std::cout << "Current lux: " << getLux();
  46. std::cout << std::endl << "Current IR: " << getIR() << std::endl << std::endl;
  47. usleep(1000000);
  48. }
  49. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:3:21: fatal error: TSL2561.h: No such file or directory
 #include "TSL2561.h"
                     ^
compilation terminated.
stdout
Standard output is empty