Simple demo of VL6180x explorer shield with Nucleo F401 based on work by SparkFun.

Dependencies:   VL6180x mbed

Simple demo program for Nucleo VL6180 Explorer shield from ST mounted on Nucleo F401. Based on work from SparkFun Electronics.

Shows basic function of Ambient Light Sensor and Time of Flight Distance sensor. Values readable over standard serial port.

Revision:
2:3de053b7541f
Parent:
1:126b6cd0f4f5
Child:
3:0ac797e55e49
--- a/main.cpp	Sun May 10 19:10:32 2015 +0000
+++ b/main.cpp	Fri Jun 17 17:13:35 2016 +0000
@@ -42,7 +42,6 @@
 VL6180xIdentification identification;
 // mbed uses 8bit addresses shift address by 1 bit left
 VL6180x sensor(D14, D15, VL6180X_ADDRESS<<1);
-
 void printIdentification(struct VL6180xIdentification *temp){
   printf("Model ID = ");
   printf("%d\n",temp->idModel);
@@ -70,6 +69,7 @@
   printf("%d\n",(temp->idTime * 2));
   printf("\n\n");
 }
+
 int main() {
 
   wait_ms(100); // delay .1s
@@ -83,10 +83,28 @@
 
   sensor.VL6180xDefautSettings(); //Load default settings to get started.
   
-    wait_ms(1000); // delay 1s
-
-    
-    
+  wait_ms(1000); // delay 1s
+ 
+      printf("Ambient Light Level (Lux) = ");
+      printf("%f\n",sensor.getAmbientLight(GAIN_1) );
+  
+  wait_ms(1000); // delay 1s
+  //
+  printf("Change sensor address to 0x27\n");
+  sensor.changeAddress(0x29,0x27);
+  sensor.getIdentification(&identification); // Retrieve manufacture info from device memory
+  printIdentification(&identification); // Helper function to print all the Module information
+  printf("Ambient Light Level (Lux) = ");
+  printf("%f\n",sensor.getAmbientLight(GAIN_1) );   
+  
+  wait_ms(1000); // delay 1s
+  printf("Change sensor address back to 0x29\n");
+  sensor.changeAddress(0x27,0x29);
+  sensor.getIdentification(&identification); // Retrieve manufacture info from device memory
+  printIdentification(&identification); // Helper function to print all the Module information
+  printf("Ambient Light Level (Lux) = ");
+  printf("%f\n",sensor.getAmbientLight(GAIN_1) );   
+ 
     while(1) {
   //Get Ambient Light level and report in LUX
       printf("Ambient Light Level (Lux) = ");
@@ -106,8 +124,12 @@
   //Get Distance and report in mm
       printf("Distance measured (mm) = ");
       printf("%d\n", sensor.getDistance() ); 
+  //Get Distance and report in mm
+      printf("Distance measured (m) = ");
+      printf("%f\n", sensor.getDistance_m() ); 
 
-      wait_ms(500);  
+      wait_ms(500); 
+ 
     }
 }