Full application
Dependencies: mbed libTCS34725 lib_LoRaWAN
main.cpp
- Committer:
- dsubotic
- Date:
- 2019-01-16
- Revision:
- 3:67413b100ac3
- Parent:
- 2:7040e447d0df
- Child:
- 4:5596b326cd34
File content as of revision 3:67413b100ac3:
#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() { delay = 0.1; // 100 ms } void BTN1released() { delay = 0.5; // 500 ms } int main() { uint16_t r,g,b,c; // Assign functions to button1 button1.fall(&BTN1pressed); button1.rise(&BTN1released); //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); } }