Program that runs lux sensor
Dependencies: TSL2561_library mbed
main.cpp@0:2aa94ec9943c, 2015-08-04 (annotated)
- Committer:
- eawendtjr
- Date:
- Tue Aug 04 17:15:16 2015 +0000
- Revision:
- 0:2aa94ec9943c
Library written but not quite working.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
eawendtjr | 0:2aa94ec9943c | 1 | #include "mbed.h" |
eawendtjr | 0:2aa94ec9943c | 2 | #include "TSL2561.h" |
eawendtjr | 0:2aa94ec9943c | 3 | |
eawendtjr | 0:2aa94ec9943c | 4 | Serial pc(USBTX, USBRX); |
eawendtjr | 0:2aa94ec9943c | 5 | |
eawendtjr | 0:2aa94ec9943c | 6 | TSL2561 luxsensor(p22, p20); |
eawendtjr | 0:2aa94ec9943c | 7 | |
eawendtjr | 0:2aa94ec9943c | 8 | /*void setup(void) |
eawendtjr | 0:2aa94ec9943c | 9 | { |
eawendtjr | 0:2aa94ec9943c | 10 | pc.baud(9600); |
eawendtjr | 0:2aa94ec9943c | 11 | |
eawendtjr | 0:2aa94ec9943c | 12 | if (luxsensor.begin()) |
eawendtjr | 0:2aa94ec9943c | 13 | { |
eawendtjr | 0:2aa94ec9943c | 14 | pc.printf("Found Sensor\r\n"); |
eawendtjr | 0:2aa94ec9943c | 15 | } |
eawendtjr | 0:2aa94ec9943c | 16 | else |
eawendtjr | 0:2aa94ec9943c | 17 | { |
eawendtjr | 0:2aa94ec9943c | 18 | pc.printf("No Sensor\r\n"); |
eawendtjr | 0:2aa94ec9943c | 19 | //while(1); |
eawendtjr | 0:2aa94ec9943c | 20 | } |
eawendtjr | 0:2aa94ec9943c | 21 | }*/ |
eawendtjr | 0:2aa94ec9943c | 22 | |
eawendtjr | 0:2aa94ec9943c | 23 | |
eawendtjr | 0:2aa94ec9943c | 24 | |
eawendtjr | 0:2aa94ec9943c | 25 | int main() { |
eawendtjr | 0:2aa94ec9943c | 26 | |
eawendtjr | 0:2aa94ec9943c | 27 | //setup(); |
eawendtjr | 0:2aa94ec9943c | 28 | |
eawendtjr | 0:2aa94ec9943c | 29 | luxsensor.setGain(TSL2561_GAIN_16X); |
eawendtjr | 0:2aa94ec9943c | 30 | luxsensor.setTiming(TSL2561_INTEGRATIONTIME_13MS); |
eawendtjr | 0:2aa94ec9943c | 31 | |
eawendtjr | 0:2aa94ec9943c | 32 | while(1) { |
eawendtjr | 0:2aa94ec9943c | 33 | uint16_t vis = luxsensor.getLuminosity(TSL2561_VISIBLE); |
eawendtjr | 0:2aa94ec9943c | 34 | pc.printf("%d luminosity\r\n", vis); |
eawendtjr | 0:2aa94ec9943c | 35 | wait(1); |
eawendtjr | 0:2aa94ec9943c | 36 | } |
eawendtjr | 0:2aa94ec9943c | 37 | } |