zhaw_st16b_pes2_10 / Mbed 2 deprecated PES_Official-TestF

Dependencies:   Servo ServoArm mbed

Fork of PES_Official by zhaw_st16b_pes2_10

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Ultraschall.h Source File

Ultraschall.h

00001 #ifndef ULTRASCHALL_H
00002 #define ULTRASCHALL_H
00003  
00004 #include "mbed.h"
00005  
00006 /** Ultraschall Class(es)
00007  */
00008  
00009 class Ultraschall
00010 {
00011 public:
00012     /** Create a Ultraschall object connected to the specified pin
00013     * @param pin i/o pin to connect to
00014     */
00015     Ultraschall();
00016     Ultraschall(PinName TrigPin,PinName EchoPin);
00017     ~Ultraschall();
00018  
00019     /** Return the distance from obstacle in cm
00020     * @param distance in cms and returns -1, in case of failure
00021     */ 
00022     unsigned int get_dist_cm(void);
00023     /** Return the pulse duration equal to sonic waves travelling to obstacle and back to receiver.
00024     * @param pulse duration in microseconds.
00025     */
00026     unsigned int get_pulse_us(void);
00027     /** Generates the trigger pulse of 10us on the trigger PIN.
00028     */
00029     void start(void);
00030     void isr_rise(void);
00031     void isr_fall(void);
00032     void fall (void (*fptr)(void));
00033     void rise (void (*fptr)(void));
00034  
00035  
00036  
00037 private:
00038  
00039     Timer pulsetime;
00040     DigitalOut  trigger;
00041     InterruptIn echo;
00042     unsigned int pulsedur;
00043     unsigned int distance;
00044 };
00045  
00046 #endif
00047