Hexiwear TSL2561 Thanks for Kenji Arai
main.cpp@0:c9d717ad98fe, 2018-02-20 (annotated)
- Committer:
- i_am_kitsune
- Date:
- Tue Feb 20 05:37:05 2018 +0000
- Revision:
- 0:c9d717ad98fe
Hexiwear TSL2561 101
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| i_am_kitsune | 0:c9d717ad98fe | 1 | #include "mbed.h" |
| i_am_kitsune | 0:c9d717ad98fe | 2 | #include "TSL2561.h" |
| i_am_kitsune | 0:c9d717ad98fe | 3 | Serial pc(USBTX, USBRX); // Serial interface |
| i_am_kitsune | 0:c9d717ad98fe | 4 | DigitalOut sensorPowerEn(PTB12); |
| i_am_kitsune | 0:c9d717ad98fe | 5 | DigitalOut led1(LED1); |
| i_am_kitsune | 0:c9d717ad98fe | 6 | |
| i_am_kitsune | 0:c9d717ad98fe | 7 | TSL2561 lum(PTB1,PTB0); // TSL2561 SDA, SCL |
| i_am_kitsune | 0:c9d717ad98fe | 8 | // main() runs in its own thread in the OS |
| i_am_kitsune | 0:c9d717ad98fe | 9 | int main() { |
| i_am_kitsune | 0:c9d717ad98fe | 10 | |
| i_am_kitsune | 0:c9d717ad98fe | 11 | sensorPowerEn = 0; |
| i_am_kitsune | 0:c9d717ad98fe | 12 | pc.baud(115200); |
| i_am_kitsune | 0:c9d717ad98fe | 13 | printf("who am i : %d \r\n", lum.who_am_i()); |
| i_am_kitsune | 0:c9d717ad98fe | 14 | |
| i_am_kitsune | 0:c9d717ad98fe | 15 | while (true) { |
| i_am_kitsune | 0:c9d717ad98fe | 16 | led1 = !led1; |
| i_am_kitsune | 0:c9d717ad98fe | 17 | printf("Illuminance: %+7.2f [Lux]\r\n", lum.lux()); |
| i_am_kitsune | 0:c9d717ad98fe | 18 | wait(0.5); |
| i_am_kitsune | 0:c9d717ad98fe | 19 | |
| i_am_kitsune | 0:c9d717ad98fe | 20 | } |
| i_am_kitsune | 0:c9d717ad98fe | 21 | } |
| i_am_kitsune | 0:c9d717ad98fe | 22 |