Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- guilhemMBED
- Date:
- 2019-11-22
- Revision:
- 1:7cd9426abb58
- Parent:
- 0:eace82fb39de
- Child:
- 2:924e2280acf4
File content as of revision 1:7cd9426abb58:
#include "mbed.h" #include "glibr.h" Serial USB_link(USBTX, USBRX); // USB initialization glibr GSensor(D4,D5); // I²C initialization : D4 = SDA ; D5 = SCL int main (void) { USB_link.baud(115200); USB_link.format(8, SerialBase::None, 1); uint16_t r,g,b; if (GSensor.ginit()) { USB_link.printf("APDS-9960 initialization complete\n\r"); } else { USB_link.printf("Something went wrong during APDS-9960 init\n\r"); } // GSensor.disableGestureSensor(); // GSensor.disableProximitySensor(); if( GSensor.enableLightSensor(true)) { // enables light sensor USB_link.printf("light sensor enabled\n\r"); } else { USB_link.printf("Something went wrong with the light sensor\n\r"); } /* if(GSensor.setLEDDrive(0x00)) { // led current : 100mA USB_link.printf("led current set at 100 mA\n\r"); } else { USB_link.printf("Something went wrong during LED initialization\n\r"); }*/ while(1) { //r = GSensor.getMode(); // USB_link.printf("mode :%hx ",r); if (GSensor.readRedLight(r)) { // USB_link.printf(" R :%4hu ",r); } else { USB_link.printf("Something went wrong during red value reading\n\r"); } if (GSensor.readGreenLight(g)) { //USB_link.printf(" G :%4hu ",r); } else { USB_link.printf("Something went wrong during green value reading\n\r"); } if (GSensor.readBlueLight(b)) { // USB_link.printf(" B :%4hu\r\n",r); } else { USB_link.printf("Something went wrong during blue value reading\n\r"); } // affichage couleur if (r >30) { USB_link.printf("red \r\n"); } if (g >30) { USB_link.printf("green \r\n"); } if ((g<30)&&(r<30)) { USB_link.printf("no color \r\n"); } } return 0; }