first question, has anyone done this and has a code example? I am struggling to get this to work properly.
Second question, anyone have any idea why this isn't working,
.cpp
IRRangeFinder::IRRangeFinder (PinName pin): _pin(pin) {
};
// returns value for range, greater than 4, 5, 6, 7, 8, 10, 12, 14, 20, 25, 30 cm
int read(void) {
float temp = _pin.read();// complier error, _pin not declared(E20)
if ( temp<0.1212) {
return 30;
}
.h
class IRRangeFinder {
public:
// @param ain analog in from sensor
IRRangeFinder (PinName pin);
// returns value for range, greater than 4, 5, 6, 7, 8, 10, 12, 14, 20, 25, 30 cm
int read(void);
//returns value for floating point given by analog in
float read_f(void);
//returns value for voltage, given by (1/3.3)*(read_f)
float read_v(void);
protected:
AnalogIn _pin;
};
the mbed.h and header files are included.
its probably glaringly obvious, but I can't see it.
first question, has anyone done this and has a code example? I am struggling to get this to work properly.
Second question, anyone have any idea why this isn't working,
.cpp
its probably glaringly obvious, but I can't see it.