Full application
Dependencies: mbed libTCS34725 lib_LoRaWAN
Diff: main.cpp
- Revision:
- 3:67413b100ac3
- Parent:
- 2:7040e447d0df
- Child:
- 4:5596b326cd34
--- a/main.cpp Wed Jan 16 13:40:11 2019 +0000 +++ b/main.cpp Wed Jan 16 15:24:23 2019 +0000 @@ -1,9 +1,14 @@ #include "mbed.h" +#include "Sht31.h" +#include "TCS34725.h" InterruptIn button1(PG_0); Serial pc(USBTX, USBRX); DigitalOut ledRED(PD_14); +//Sht31 Sht31(PB_9,PB_8); +TCS34725 colorSens(PB_9,PB_8); +float relHumidity, temperature; double delay = 0.5; // 500 ms void BTN1pressed() @@ -18,6 +23,8 @@ int main() { + uint16_t r,g,b,c; + // Assign functions to button1 button1.fall(&BTN1pressed); button1.rise(&BTN1released); @@ -25,8 +32,15 @@ //serial communication pc.baud(115200); pc.printf("Welcome at University of Antwerp #STEM2019 \r\n"); + + if(!colorSens.init(0xD5, 0x03)){ + pc.printf("ERROR\n"); //check to see if i2c is responding + } while (1) { + //pc.printf("temp: %f \r\n", Sht31.readTemperature()); + colorSens.getColor(r,g,b,c); //pass variables by reference... + pc.printf("DATA: Red: %d Green: %d Blue: %d Clear: %d \r\n", r, g, b, c); ledRED = !ledRED; wait(delay); }