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);
    }
}

History

Add getImageSensorData() function. default tip

2014-11-26, by matsujirushi [Wed, 26 Nov 2014 12:00:04 +0000] rev 1

Add getImageSensorData() function.


Create MjGP2Y0E03 class.

2014-11-24, by matsujirushi [Mon, 24 Nov 2014 07:51:53 +0000] rev 0

Create MjGP2Y0E03 class.