![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Drivers for Pololu irs09a short range infra red sensor.
Dependencies: mbed
Diff: ShortRangeSensor.h
- Revision:
- 0:fba97a03cd3c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ShortRangeSensor.h Fri Mar 25 22:09:43 2016 +0000 @@ -0,0 +1,32 @@ +#ifndef SHORTRANGESENSOR_H +#define SHORTRANGESENSOR_H + +#include "mbed.h" + +//constants for i2c communication +const int ADDR = 0x52; +const char SYSRANGE__START_SAMPLE[] = {0x00,0x18,0x01}; +const char RESULT__RANGE_VAL[] = {0x00,0x62}; +const char RESULT__RANGE_STATUS[] = {0x00,0x4D}; +const char SYSRANGE__RANGE_CHECK_ENABLES[] = {0x00,0x2D,0x10}; +const char SYSRANGE__PART_TO_PART_RANGE_OFFSET_INIT[] = {0x00,0x24,0x00}; //once correct offset is found, chage 0x00 to correct offset +const char SYSRANGE__PART_TO_PART_RANGE_OFFSET[] = {0x00,0x24}; + +class ShortRangeSensor +{ + public: + ShortRangeSensor(PinName sda, PinName scl); + //returns range in mm + int getRange(); + //returns value of status register + int getStatus(); + //returns value of part to part range offset register + int getPPOffset(); + //sets value of part to part range offset register, -128 to 128 + void setPPOffset(int offset); + + private: + I2C i2c; +}; + +#endif \ No newline at end of file