
Calculo para utilizar o VL53L0X
Revision 0:6507f9fee04d, committed 2020-07-23
- Comitter:
- Mateusjesus
- Date:
- Thu Jul 23 22:23:41 2020 +0000
- Commit message:
- VL530X
Changed in this revision
diff -r 000000000000 -r 6507f9fee04d VL53L0X.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/VL53L0X.lib Thu Jul 23 22:23:41 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/joelvonrotz/code/VL53L0X/#ccc67c76fecb
diff -r 000000000000 -r 6507f9fee04d main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Jul 23 22:23:41 2020 +0000 @@ -0,0 +1,44 @@ +//Multiple Sensors +#include"mbed.h" +#include"VL53L0X.h" +uint16_t measure[3] = {0,0,0}; +int zero_um[3] = {0,0,0}; +int total = 0; +#define DIS_MAX 500; //Distância maxima a partir da qual o inimigo será detectado +I2C i2c(p9, p10); +VL53L0X v1_sensors[3] = {(&i2c),(&i2c),(&i2c)}; +BusOut v1_shutdown(p11,p12,p13); +Serial bt(p28, p27); +void Search() +{ + int i; + uint8_t expander_shutdown_mask = 1; + for(uint8_t i=0;i<3;i++) + { + v1_shutdown=expander_shutdown_mask; + expander_shutdown_mask = (expander_shutdown_mask << 1) + 1; + v1_sensors[i].init(); + v1_sensors[i].setDeviceAddress(0x40 + i); + v1_sensors[i].setModeContinuous(); + v1_sensors[i].startContinuous(); + } + for(uint8_t i = 0; i < 3 ; i++) + { + measure[i]=v1_sensors[i].getRangeMillimeters(); + wait(0.001); + } + for (i=0; i<3; i++) + { + if (measure[i] < 100) {zero_um[i] = 1;} + else {zero_um[i] = 0;} + } + total = zero_um[0]*100 + zero_um[1]*10 + zero_um[2]; +} +int main() +{ + while(1) + { + Search(); + bt.printf("%i \n\r",total); + } +} \ No newline at end of file
diff -r 000000000000 -r 6507f9fee04d mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Jul 23 22:23:41 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file