Capteur ST

Dependencies:   VL6180x mbed Servo

Fork of VL6180X_Explorer by Ian Kilburn

Revision:
2:083c1efc951f
Parent:
1:126b6cd0f4f5
Child:
3:27076d13c756
diff -r 126b6cd0f4f5 -r 083c1efc951f main.cpp
--- a/main.cpp	Sun May 10 19:10:32 2015 +0000
+++ b/main.cpp	Thu Sep 10 12:32:36 2015 +0000
@@ -39,9 +39,13 @@
 
 #define VL6180X_ADDRESS 0x29
 
+DigitalInOut sda_D(PB_9);
+DigitalInOut scl_D(PB_8);
+
+
 VL6180xIdentification identification;
 // mbed uses 8bit addresses shift address by 1 bit left
-VL6180x sensor(D14, D15, VL6180X_ADDRESS<<1);
+VL6180x sensor_D(PB_9, PB_8, VL6180X_ADDRESS<<1);
 
 void printIdentification(struct VL6180xIdentification *temp){
   printf("Model ID = ");
@@ -73,42 +77,24 @@
 int main() {
 
   wait_ms(100); // delay .1s
+  sda_D.mode(PullUp);
+  scl_D.mode(PullUp);
+  //sensor_D.getIdentification(&identification); // Retrieve manufacture info from device memory
+  //printIdentification(&identification); // Helper function to print all the Module information
 
-  sensor.getIdentification(&identification); // Retrieve manufacture info from device memory
-  printIdentification(&identification); // Helper function to print all the Module information
-
-  if(sensor.VL6180xInit() != 0){
+  if(sensor_D.VL6180xInit() != 0){
         printf("FAILED TO INITALIZE\n"); //Initialize device and check for errors
   }; 
 
-  sensor.VL6180xDefautSettings(); //Load default settings to get started.
+  sensor_D.VL6180xDefautSettings(); //Load default settings to get started.
+  wait_ms(100); // delay
   
-    wait_ms(1000); // delay 1s
-
-    
-    
-    while(1) {
-  //Get Ambient Light level and report in LUX
-      printf("Ambient Light Level (Lux) = ");
+  while(1) {
   
-  //Input GAIN for light levels, 
-  // GAIN_20     // Actual ALS Gain of 20
-  // GAIN_10     // Actual ALS Gain of 10.32
-  // GAIN_5      // Actual ALS Gain of 5.21
-  // GAIN_2_5    // Actual ALS Gain of 2.60
-  // GAIN_1_67   // Actual ALS Gain of 1.72
-  // GAIN_1_25   // Actual ALS Gain of 1.28
-  // GAIN_1      // Actual ALS Gain of 1.01
-  // GAIN_40     // Actual ALS Gain of 40
-  
-      printf("%f\n",sensor.getAmbientLight(GAIN_1) );
-
-  //Get Distance and report in mm
-      printf("Distance measured (mm) = ");
-      printf("%d\n", sensor.getDistance() ); 
-
-      wait_ms(500);  
-    }
+      printf("capteur: %d\n\r", sensor_D.getDistance());
+      //printf("capteur gauche: %d\n\r",/*sensor_G.getAmbientLight(GAIN_1),*/ sensor_G.getDistance());
+      wait_ms(1000);  
+  }
 }