TomYumBoys / Mbed 2 deprecated MM2017

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ir_sensor.h Source File

ir_sensor.h

00001 #ifndef IR_H
00002 #define IR_H
00003 #include "mbed.h"
00004 extern Serial pc;
00005 
00006 class IRSensor {
00007 public:
00008     DigitalOut _enable;
00009     AnalogIn _input;
00010   //  volatile short value; 
00011   
00012     IRSensor(PinName enable, PinName input) : _enable(enable), _input(input){}
00013 
00014     // Calculate an estimated IR value
00015     float readIR();
00016 
00017     //Get the number of cells away wall is
00018 //    short cell_dist();
00019 
00020     //Shorthand for read()
00021     operator short() {
00022         return readIR();
00023     }
00024 };
00025 
00026 extern IRSensor rightIR;
00027 extern IRSensor rightDiagonalIR;
00028 extern IRSensor leftDiagonalIR;
00029 /*
00030 extern IRSensor rightDiagonalIR;
00031 extern IRSensor rightFrontIR;
00032 extern IRSensor leftFrontIR;
00033 extern IRSensor leftDiagonalIR;
00034 */
00035 extern IRSensor leftIR;
00036 
00037 
00038 #endif