IoT based Smart Garbage Monitoring System-Debjyoti, Avinash, Seeta Ram

Dependents:   frdm_group2P1

Committer:
seetarampandey
Date:
Thu Dec 06 15:32:07 2018 +0000
Revision:
0:1ad2b17e0f45
IoT based Smart Garbage Monitoring System- Debjyoti, Avinash, Seeta Ram

Who changed what in which revision?

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