Code-Basis für Programm zum Taster-Entprellen
Fork of Laser-Distance by
main.cpp@3:1ed9495c9158, 2017-11-02 (annotated)
- Committer:
- andcor02
- Date:
- Thu Nov 02 10:43:07 2017 +0000
- Revision:
- 3:1ed9495c9158
- Parent:
- 2:587b4d7444d1
- Child:
- 4:ef7abafa9884
Sets up LCD and prints sensor data value of TSL2561 light sensor to LCD
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andcor02 | 0:80032665d37e | 1 | #include "mbed.h" |
andcor02 | 0:80032665d37e | 2 | #include "C12832.h" |
andcor02 | 3:1ed9495c9158 | 3 | #include "TSL2561.h" |
andcor02 | 0:80032665d37e | 4 | |
andcor02 | 0:80032665d37e | 5 | /* Sets up LCD and prints sensor data value of Indoor Air Quality sensor to LCD */ |
andcor02 | 0:80032665d37e | 6 | |
andcor02 | 0:80032665d37e | 7 | C12832 lcd(PE_14, PE_12, PD_12, PD_11, PE_9); //LCD: MOSI, SCK, RESET, A0, nCS |
andcor02 | 3:1ed9495c9158 | 8 | TSL2561 tsl2561(PF_0, PF_1, TSL2561_ADDR_HIGH); //LIGHT SENSOR: I2C_SDA, I2C_SCL |
andcor02 | 0:80032665d37e | 9 | |
andcor02 | 0:80032665d37e | 10 | int main() |
andcor02 | 0:80032665d37e | 11 | { |
andcor02 | 3:1ed9495c9158 | 12 | tsl2561.begin(); |
andcor02 | 3:1ed9495c9158 | 13 | tsl2561.setGain(TSL2561_GAIN_0X); |
andcor02 | 3:1ed9495c9158 | 14 | tsl2561.setTiming(TSL2561_INTEGRATIONTIME_402MS); |
andcor02 | 3:1ed9495c9158 | 15 | |
andcor02 | 0:80032665d37e | 16 | while(1) { |
andcor02 | 3:1ed9495c9158 | 17 | int x = tsl2561.getLuminosity(TSL2561_VISIBLE); |
andcor02 | 3:1ed9495c9158 | 18 | int z = tsl2561.getLuminosity(TSL2561_INFRARED); |
andcor02 | 3:1ed9495c9158 | 19 | |
andcor02 | 3:1ed9495c9158 | 20 | lcd.cls(); |
andcor02 | 0:80032665d37e | 21 | lcd.locate(0,3); |
andcor02 | 3:1ed9495c9158 | 22 | lcd.printf("[LIGHT]"); |
andcor02 | 3:1ed9495c9158 | 23 | lcd.locate(0,14); |
andcor02 | 3:1ed9495c9158 | 24 | lcd.printf("VIS: %d, INFR: %d ",x, z); |
andcor02 | 3:1ed9495c9158 | 25 | wait(1); // Print to LCD values |
andcor02 | 0:80032665d37e | 26 | } |
andcor02 | 2:587b4d7444d1 | 27 | } |