Full application
Dependencies: mbed libTCS34725 lib_LoRaWAN
main.cpp
- Committer:
- dsubotic
- Date:
- 2019-01-16
- Revision:
- 5:c64f313ca878
- Parent:
- 4:5596b326cd34
- Child:
- 6:6ae3c5bca801
File content as of revision 5:c64f313ca878:
#include "mbed.h" #include "Sht31.h" #include "TCS34725.h" InterruptIn button1(PG_0); InterruptIn button2(PG_1); Serial pc(USBTX, USBRX); DigitalOut ledRED(PD_14); DigitalOut ledGreen(PB_0); DigitalOut ledBlue(PD_15); //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 } void BTN2pressed() { //Andere code nodig delay = 0.1; // 100 ms } void BTN2released() { //andere code nodig delay = 0.5; // 500 ms } int main() { uint16_t r,g,b,c; // Assign functions to button1 button1.fall(&BTN1pressed); button1.rise(&BTN1released); // Assign functions to button2 button2.fall(&BTN2pressed); button2.rise(&BTN2released); //Turn off RGB led ledRED = 1; ledGreen = 1; ledBlue = 1; //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); } }