![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
sef
Dependencies: mbed
Fork of Bewegungen_mit_Sensor by
Diff: IRSensor.h
- Revision:
- 0:96f88638114b
- Child:
- 1:d40ff07e2fe0
diff -r 000000000000 -r 96f88638114b IRSensor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IRSensor.h Tue Mar 21 14:57:54 2017 +0000 @@ -0,0 +1,40 @@ +/* + * IRSensor.h + * Copyright (c) 2016, ZHAW + * All rights reserved. + */ + +#ifndef IR_SENSOR_H_ +#define IR_SENSOR_H_ + +#include <cstdlib> +#include <mbed.h> + +/** + * This is a device driver class to read the distance measured with a Sharp IR sensor. + */ +class IRSensor +{ + +public: + + IRSensor(AnalogIn* distance, DigitalOut* bit0, DigitalOut* bit1, DigitalOut* bit2, int number); + IRSensor(); + + void init(AnalogIn* distance, DigitalOut* bit0, DigitalOut* bit1, DigitalOut* bit2, int number); + virtual ~IRSensor(); + float read(); + + operator float(); + +private: + + AnalogIn* distance; + DigitalOut* bit0; + DigitalOut* bit1; + DigitalOut* bit2; + + int number; +}; + +#endif /* IR_SENSOR_H_ */