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.
Diff: qaaaaa.cpp
- Revision:
- 0:50572ec0871c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/qaaaaa.cpp Fri Feb 01 08:32:05 2019 +0000 @@ -0,0 +1,52 @@ +#include "VL53L0X.h" +#include "mbed.h" +Serial pc(SERIAL_TX, SERIAL_RX); +I2C i2c_vl(D4, D5); +Timer timer_vlR[2]; +VL53L0X vlR[2] = {VL53L0X(&i2c_vl,&timer_vlR[0]),VL53L0X(&i2c_vl,&timer_vlR[1])}; +DigitalInOut XshutR[2]={DigitalInOut(D8),DigitalInOut(D9)}; +int vl_num = 2; // 私用するvl53l0xの数 +Timer t; +int val_t; +int distance[2]; +int main(){ + for(int i = 0; i < 2; i++){ + XshutR[i].output(); + XshutR[i] = 0; + } + wait(0.2); + for(int i =0;i < vl_num;i++){ + pc.printf("s-%d\n",i); + XshutR[i].input(); + wait(0.1); + pc.printf("s1-%d\n",i); + vlR[i].init(); + wait(0.1); + pc.printf("s2-%d\n",i); + vlR[i].setAddress((uint8_t)(16+i*2)); + wait(0.1); + pc.printf("s3-%d\n",i); + vlR[i].startContinuous(30); + wait(0.1); + pc.printf("s4-%d\n",i); + } + /*pc.printf("00\n"); + vlR.init(); + pc.printf("01\n"); + wait(0.1); + vlR.setAddress((uint8_t) 44); + vlR.setTimeout(1000); + wait(0.1); + pc.printf("03\n"); + vlR.startContinuous(30);*/ + while(1){ + for(int i =0; i <vl_num; i++){ + pc.printf("start\n"); + //distance[i] = vlR[i].readRangeSingleMillimeters(); + distance[i] = vlR[i].readRangeContinuousMillimeters(); + pc.printf("distance[%d] : %d\n",i,distance[i]); + } + + + } + } \ No newline at end of file