jkk

Dependencies:   mbed RGB-fun HC_SR04_Ultrasonic_Library xbee_lib

Committer:
pimani
Date:
Fri Apr 10 15:34:46 2020 +0000
Revision:
1:7fbedf384fe9
Transmitter codes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pimani 1:7fbedf384fe9 1 /* Copyright (c) 2013 Prabhu Desai
pimani 1:7fbedf384fe9 2 * pdtechworld@gmail.com
pimani 1:7fbedf384fe9 3 *
pimani 1:7fbedf384fe9 4 *
pimani 1:7fbedf384fe9 5 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
pimani 1:7fbedf384fe9 6 * and associated documentation files (the "Software"), to deal in the Software without restriction,
pimani 1:7fbedf384fe9 7 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
pimani 1:7fbedf384fe9 8 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
pimani 1:7fbedf384fe9 9 * furnished to do so, subject to the following conditions:
pimani 1:7fbedf384fe9 10 *
pimani 1:7fbedf384fe9 11 * The above copyright notice and this permission notice shall be included in all copies or
pimani 1:7fbedf384fe9 12 * substantial portions of the Software.
pimani 1:7fbedf384fe9 13 *
pimani 1:7fbedf384fe9 14 * For more details on the sensor :
pimani 1:7fbedf384fe9 15 * http://www.elecfreaks.com/store/hcsr04-ultrasonic-sensor-distance-measuring-module-p-91.html?zenid=pgm8pgnvaodbe36dibq5s1soi3
pimani 1:7fbedf384fe9 16 *
pimani 1:7fbedf384fe9 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
pimani 1:7fbedf384fe9 18 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
pimani 1:7fbedf384fe9 19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
pimani 1:7fbedf384fe9 20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
pimani 1:7fbedf384fe9 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
pimani 1:7fbedf384fe9 22 */
pimani 1:7fbedf384fe9 23
pimani 1:7fbedf384fe9 24 #ifndef MBED_HCSR04_H
pimani 1:7fbedf384fe9 25 #define MBED_HCSR04_H
pimani 1:7fbedf384fe9 26
pimani 1:7fbedf384fe9 27 #include "mbed.h"
pimani 1:7fbedf384fe9 28
pimani 1:7fbedf384fe9 29 /** HCSR04 Class(es)
pimani 1:7fbedf384fe9 30 */
pimani 1:7fbedf384fe9 31
pimani 1:7fbedf384fe9 32 class HCSR04
pimani 1:7fbedf384fe9 33 {
pimani 1:7fbedf384fe9 34 public:
pimani 1:7fbedf384fe9 35 /** Create a HCSR04 object connected to the specified pin
pimani 1:7fbedf384fe9 36 * @param pin i/o pin to connect to
pimani 1:7fbedf384fe9 37 */
pimani 1:7fbedf384fe9 38 HCSR04(PinName TrigPin,PinName EchoPin);
pimani 1:7fbedf384fe9 39 ~HCSR04();
pimani 1:7fbedf384fe9 40
pimani 1:7fbedf384fe9 41 /** Return the distance from obstacle in cm
pimani 1:7fbedf384fe9 42 * @param distance in cms and returns -1, in case of failure
pimani 1:7fbedf384fe9 43 */
pimani 1:7fbedf384fe9 44 unsigned int get_dist_cm(void);
pimani 1:7fbedf384fe9 45 /** Return the pulse duration equal to sonic waves travelling to obstacle and back to receiver.
pimani 1:7fbedf384fe9 46 * @param pulse duration in microseconds.
pimani 1:7fbedf384fe9 47 */
pimani 1:7fbedf384fe9 48 unsigned int get_pulse_us(void);
pimani 1:7fbedf384fe9 49 /** Generates the trigger pulse of 10us on the trigger PIN.
pimani 1:7fbedf384fe9 50 */
pimani 1:7fbedf384fe9 51 void start(void );
pimani 1:7fbedf384fe9 52 void isr_rise(void);
pimani 1:7fbedf384fe9 53 void isr_fall(void);
pimani 1:7fbedf384fe9 54 void fall (void (*fptr)(void));
pimani 1:7fbedf384fe9 55 void rise (void (*fptr)(void));
pimani 1:7fbedf384fe9 56
pimani 1:7fbedf384fe9 57
pimani 1:7fbedf384fe9 58
pimani 1:7fbedf384fe9 59 private:
pimani 1:7fbedf384fe9 60
pimani 1:7fbedf384fe9 61 Timer pulsetime;
pimani 1:7fbedf384fe9 62 DigitalOut trigger;
pimani 1:7fbedf384fe9 63 InterruptIn echo;
pimani 1:7fbedf384fe9 64 unsigned int pulsedur;
pimani 1:7fbedf384fe9 65 unsigned int distance;
pimani 1:7fbedf384fe9 66 };
pimani 1:7fbedf384fe9 67
pimani 1:7fbedf384fe9 68 #endif