Mechatronics Robotics / Mbed 2 deprecated robotV5

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers IRSensor.h Source File

IRSensor.h

00001 /*
00002  * IRSensor.h
00003  * Copyright (c) 2016, ZHAW
00004  * All rights reserved.
00005  */
00006 
00007 #ifndef IR_SENSOR_H_
00008 #define IR_SENSOR_H_
00009 
00010 #include <cstdlib>
00011 #include <mbed.h>
00012 
00013 /**
00014  * This is a device driver class to read the distance measured with a Sharp IR sensor.
00015  */
00016 class IRSensor
00017 {
00018 
00019 public:
00020     // constructors have same name as the class
00021     IRSensor(AnalogIn* distance, DigitalOut* bit0, DigitalOut* bit1, DigitalOut* bit2, int number);
00022     IRSensor();
00023     
00024     void        init(AnalogIn* distance, DigitalOut* bit0, DigitalOut* bit1, DigitalOut* bit2, int number);
00025     virtual     ~IRSensor();   // deconstructor
00026     float       read();
00027 
00028     operator float();
00029 
00030 private:
00031 
00032     AnalogIn*       distance;
00033     DigitalOut*     bit0;
00034     DigitalOut*     bit1;
00035     DigitalOut*     bit2;
00036 
00037     int             number;
00038 };
00039 
00040 #endif /* IR_SENSOR_H_ */