For Sharp GP2Y0E03(optical distance measurement sensor).
#include "mbed.h" #include "MjGP2Y0E03.h" using namespace matsujirushi; Serial pc(USBTX, USBRX); I2C i2c(dp5, dp27); MjGP2Y0E03 distanceSensor(&i2c, 0x80); int main() { pc.baud(115200); i2c.frequency(400000); for(;;) { uint16_t distance = distanceSensor.getDistance(); pc.printf("%4d [", distance); int i; for (i = 0; i < distance / 50; i++) { pc.putc('*'); } for (; i < 4096 / 50; i++) { pc.putc(' '); } pc.puts("]\r\n"); wait_ms(50); } }
Changes
Revision | Date | Who | Commit message |
---|---|---|---|
1:1832cde75561 | 2014-11-26 | matsujirushi | Add getImageSensorData() function. |
0:33c4a1de6547 | 2014-11-24 | matsujirushi | Create MjGP2Y0E03 class. |