Median of 3 filter for multiple time of flight sensors translated from arduino by pololu

Dependencies:   mbed

Dependents:   wheelchaircontrol wheelchaircontrol2 wheelchaircontrol3 wheelchaircontrol4 ... more

main.cpp

Committer:
jvfausto
Date:
2020-06-03
Revision:
5:a75d46c735c7
Parent:
4:f6f0c2b9120a

File content as of revision 5:a75d46c735c7:

#include "mbed.h"
#include "VL53L1X.h"

Serial pc(USBTX,USBRX);
VL53L1X sensor1(PD_13, PD_12, PA_15);   // Block 1
VL53L1X sensor2(PD_13, PD_12, PC_7);
VL53L1X sensor3(PD_13, PD_12, PB_5);

VL53L1X sensor4(PD_13, PD_12, PE_11);   // Block 2
VL53L1X sensor5(PD_13, PD_12, PF_14);
VL53L1X sensor6(PD_13, PD_12, PE_13);

VL53L1X sensor7(PD_13, PD_12, PG_15);   // Block 3
VL53L1X sensor8(PD_13, PD_12, PG_14);
VL53L1X sensor9(PD_13, PD_12, PG_9);

VL53L1X sensor10(PD_13, PD_12, PE_10);  // Block 4
VL53L1X sensor11(PD_13, PD_12, PE_12);     
VL53L1X sensor12(PD_13, PD_12, PE_14);
int main()
{  
    sensor1.initReading(0x27,50000);
    sensor2.initReading(0x35,50000);
    sensor3.initReading(0x37,50000);
    sensor4.initReading(0x39,50000);
    sensor5.initReading(0x41,50000);
    sensor6.initReading(0x43,50000);
    sensor7.initReading(0x45,50000);
    sensor8.initReading(0x47,50000);
    sensor9.initReading(0x49,50000);
    sensor10.initReading(0x51,50000);    
    sensor11.initReading(0x53,50000);
    sensor12.initReading(0x55,50000);
    while(1)
    {
      pc.printf("%d, ", sensor1.readFromOneSensor());
      pc.printf("%d, ", sensor2.readFromOneSensor());
      pc.printf("%d, ", sensor3.readFromOneSensor());      
      pc.printf("%d, ", sensor4.readFromOneSensor());
      pc.printf("%d, ", sensor5.readFromOneSensor());
      pc.printf("%d, ", sensor6.readFromOneSensor());     
      pc.printf("%d, ", sensor7.readFromOneSensor());
      pc.printf("%d, ", sensor8.readFromOneSensor());
      pc.printf("%d, ", sensor9.readFromOneSensor());
      pc.printf("%d, ", sensor10.readFromOneSensor());
      pc.printf("%d, ", sensor11.readFromOneSensor());
      pc.printf("%d, ", sensor12.readFromOneSensor());
      pc.printf("\r\n");
      /*
      pc.printf("%d hello\r\n", frontRight.readFromOneSensor()); 
      pc.printf("%d hello\r\n", frontRight2.readFromOneSensor()); 
      pc.printf("%d hello\r\n", frontRight3.readFromOneSensor()); 
      pc.printf("%d hello\r\n", frontRight4.readFromOneSensor()); */
    }
}