Dev Joshi / Mbed 2 deprecated SRF02_lib

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SRF02.h Source File

SRF02.h

00001 /*Header file for the SRF02 sonar range finder class*/
00002 #ifndef SRF02_H
00003 #define SRF02_H
00004 
00005 #include "mbed.h"
00006 
00007 //!Library for the SRF02 Ultrasonic Ranger
00008 /*!
00009 The SRF02 is an Ultrasonic range finder, with an I2C interface that allows the measurement to be read directly in centimetres
00010 */
00011 
00012 class SRF02
00013 {
00014 public:
00015     //Create an instance of the class
00016     //Connect the peripheral over I2C using pins defined by sda and scl
00017     SRF02(PinName sda, PinName scl, int addr);
00018     
00019     //Destroys an instance
00020     ~SRF02();
00021     
00022     //Read the distance in cm
00023     float distancecm();
00024     
00025     //Read the distance in in
00026     float distancein();
00027     
00028     //Read the distance in microseconds
00029     float distanceus();
00030 
00031 
00032 private:
00033     I2C m_i2c;
00034     int m_addr;
00035     
00036     
00037 };
00038 #endif