sensor test
Dependencies: S11059 VL6180X m3pi mbed
Fork of VL6180_Hello_World1 by
Revision 2:3ebca956fd36, committed 2016-07-19
- Comitter:
- maruta
- Date:
- Tue Jul 19 03:51:32 2016 +0000
- Parent:
- 1:6340d62d759f
- Commit message:
- sensor test
Changed in this revision
--- a/S11059-SoftI2C.lib Tue Jul 19 00:53:45 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://developer.mbed.org/users/maruta/code/S11059-SoftI2C/#ea48b39e69bd
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/S11059.lib Tue Jul 19 03:51:32 2016 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/maruta/code/S11059/#61de426fb945
--- a/VL6180.lib Tue Jul 19 00:53:45 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://developer.mbed.org/users/sburg/code/VL6180/#5d61f202b1bd
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/VL6180X.lib Tue Jul 19 03:51:32 2016 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/maruta/code/VL6180X/#8aca38272614
--- 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