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@0:eace82fb39de, 2019-11-14 (annotated)
- Committer:
- guilhemMBED
- Date:
- Thu Nov 14 21:31:52 2019 +0000
- Revision:
- 0:eace82fb39de
- Child:
- 1:7cd9426abb58
test lecture rouge;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
guilhemMBED | 0:eace82fb39de | 1 | #include "mbed.h" |
guilhemMBED | 0:eace82fb39de | 2 | #include "glibr.h" |
guilhemMBED | 0:eace82fb39de | 3 | |
guilhemMBED | 0:eace82fb39de | 4 | Serial USB_link(USBTX, USBRX); // USB initialization |
guilhemMBED | 0:eace82fb39de | 5 | glibr GSensor(D4,D5); // I²C initialization : D4 = SDA ; D5 = SCL |
guilhemMBED | 0:eace82fb39de | 6 | |
guilhemMBED | 0:eace82fb39de | 7 | |
guilhemMBED | 0:eace82fb39de | 8 | int main (void) { |
guilhemMBED | 0:eace82fb39de | 9 | |
guilhemMBED | 0:eace82fb39de | 10 | USB_link.baud(115200); |
guilhemMBED | 0:eace82fb39de | 11 | USB_link.format(8, SerialBase::None, 1); |
guilhemMBED | 0:eace82fb39de | 12 | uint16_t r=0,g=0; |
guilhemMBED | 0:eace82fb39de | 13 | if (GSensor.ginit()) { |
guilhemMBED | 0:eace82fb39de | 14 | USB_link.printf("APDS-9960 initialization complete\n\r"); |
guilhemMBED | 0:eace82fb39de | 15 | } |
guilhemMBED | 0:eace82fb39de | 16 | else { |
guilhemMBED | 0:eace82fb39de | 17 | USB_link.printf("Something went wrong during APDS-9960 init\n\r"); |
guilhemMBED | 0:eace82fb39de | 18 | } |
guilhemMBED | 0:eace82fb39de | 19 | if(GSensor.setLEDDrive(0x00)){ // led current : 100mA |
guilhemMBED | 0:eace82fb39de | 20 | USB_link.printf("led current set at 100 mA\n\r"); |
guilhemMBED | 0:eace82fb39de | 21 | } else { |
guilhemMBED | 0:eace82fb39de | 22 | USB_link.printf("Something went wrong during LED initialization\n\r"); |
guilhemMBED | 0:eace82fb39de | 23 | } |
guilhemMBED | 0:eace82fb39de | 24 | while(1) { |
guilhemMBED | 0:eace82fb39de | 25 | if (GSensor.readRedLight(r)){ |
guilhemMBED | 0:eace82fb39de | 26 | USB_link.printf("red value was aquired\n\r"); |
guilhemMBED | 0:eace82fb39de | 27 | } else { |
guilhemMBED | 0:eace82fb39de | 28 | USB_link.printf("Something went wrong during red value reading\n\r"); |
guilhemMBED | 0:eace82fb39de | 29 | } |
guilhemMBED | 0:eace82fb39de | 30 | USB_link.printf("red :%d\r\n",r); |
guilhemMBED | 0:eace82fb39de | 31 | } |
guilhemMBED | 0:eace82fb39de | 32 | return 0; |
guilhemMBED | 0:eace82fb39de | 33 | } |