sensor test
Dependencies: S11059 VL6180X m3pi mbed
Fork of VL6180_Hello_World1 by
Diff: main.cpp
- Revision:
- 2:3ebca956fd36
- Parent:
- 1:6340d62d759f
--- a/main.cpp Tue Jul 19 00:53:45 2016 +0000 +++ b/main.cpp Tue Jul 19 03:51:32 2016 +0000 @@ -1,11 +1,11 @@ -#include "VL6180.h" +#include "VL6180X.h" #include "mbed.h" #include "m3pi.h" -#include "S11059-SoftI2C.h" +#include "S11059.h" -VL6180 rf(p28, p27); //I2C sda and scl +VL6180x rf(p28, p27); //I2C sda and scl Serial pc(USBTX, USBRX); //USB serial -S11059 col(p19,p20); +S11059 col(p28,p27); m3pi m3pi; Timer t; @@ -16,27 +16,36 @@ m3pi.locate(0,1); m3pi.printf("Check"); wait(1); - float reading; + int reading; float time[2]; int bl=0; char buf[255]; + m3pi.cls(); + rf.VL6180xInit(); + rf.VL6180xDefautSettings(); - m3pi.cls(); while(1) { m3pi.cls(); t.start(); time[0] = t.read(); - reading = rf; + rf.triggerDistance(); + reading = rf.pollDistance(); t.stop(); time[1] = t.read(); - - + col.update(); + bl = col.b; int len = 0; - //m3pi.locate(0,0); - //len = sprintf(buf,"%f",reading); + m3pi.locate(0,0); + m3pi.printf("%dmm",reading); + +// m3pi.locate(0,1); +// m3pi.printf("%d",bl); + m3pi.locate(0,1); - m3pi.printf("%f",time[1]-time[0]); - pc.printf("Read %4.1f cm\n\r", reading); + m3pi.printf("%.3fms",(time[1]-time[0])*1000); + + pc.printf("Read %d mm\n\r", reading); m3pi.print(buf,len); + wait_ms(100); } } \ No newline at end of file