File tree Expand file tree Collapse file tree 9 files changed +113
-1
lines changed
Expand file tree Collapse file tree 9 files changed +113
-1
lines changed Original file line number Diff line number Diff line change 1- # hcsr04
1+ = HCSR04 ultrasonic sensor Library for Arduino =
2+ ==========
3+ HCSR04 is an [ Arduino] ( http://arduino.cc ) library HCSR04 Sensors
4+
5+ ![ HC-SR04] ( HC_SR04.jpg )
6+
7+ Documentation
8+ -------------
9+ Documentation for the library is on the
10+ [ Github Project Pages] ( https://github.com/gamegine/HCSR04-ultrasonic-sensor-lib )
11+
12+ [ basic example] ( examples/HCSR04/HCSR04.ino )
13+
14+ ![ schéma] ( examples/HCSR04/HC_SR04_cabling.jpg )
15+ ``` ino
16+ #include < HCSR04.h>
17+
18+ HCSR04 hc (2,3);//initialisation class HCSR04 (trig pin , echo pin)
19+
20+ void setup()
21+ { Serial.begin(9600); }
22+
23+ void loop()
24+ { Serial.println( hc.dist() ); } //return current distance (cm) in serial
25+ ```
26+
27+ Download
28+ --------
29+ The last version of the Library is available on the github
30+ [HCSR04 Page](https://github.com/gamegine/HCSR04-ultrasonic-sensor-lib/releases)
31+
32+
33+ Install
34+ -------
35+ The library can be installed using the [standard Arduino library install procedure](http://arduino.cc/en/Guide/Libraries)
36+
37+ [License](https://github.com/gamegine/HCSR04-ultrasonic-sensor-lib/blob/master/LICENSE)
38+ -------
39+ [MIT License](https://github.com/gamegine/HCSR04-ultrasonic-sensor-lib/blob/master/LICENSE)
Original file line number Diff line number Diff line change 1+ theme : jekyll-theme-slate
Original file line number Diff line number Diff line change 1+ #include < HCSR04.h>
2+
3+ HCSR04 hc (5 ,6 );// initialisation class HCSR04 (trig pin , echo pin)
4+
5+ void setup ()
6+ { Serial.begin (9600 ); }
7+
8+ void loop ()
9+ { Serial.println ( hc.dist () ); }// return curent distance in serial
Original file line number Diff line number Diff line change 1+ #######################################
2+ # Syntax Coloring Map for HCSR04 #
3+ #######################################
4+
5+ #######################################
6+ # Datatypes (KEYWORD1) #
7+ #######################################
8+
9+ HCSR04 KEYWORD1
10+
11+ #######################################
12+ # Methods and Functions (KEYWORD2) #
13+ #######################################
14+
15+ dist KEYWORD2
16+
17+ #######################################
18+ # Constants (LITERAL1) #
19+ #######################################
Original file line number Diff line number Diff line change 1+ name =HCSR04 ultrasonic sensor
2+ version =1.0.0
3+ author =gamegine
4+ maintainer =gamegine
5+ sentence =Allows an Arduino board to use HCSR04 module.
6+ paragraph =This library allows an Arduino board to use HCSR04 module for get current distance in cm. On the Arduino.
7+ category =Sensors
8+ url =https://github.com/gamegine/HCSR04-ultrasonic-sensor-lib
9+ architectures =*
Original file line number Diff line number Diff line change 1+ #include " HCSR04.h"
2+ // //////////////////////////////////consttruct/destruct
3+ HCSR04::HCSR04 (int out,int echo)
4+ {
5+ this ->out = out;
6+ this ->echo = echo;
7+ pinMode (this ->out , OUTPUT);
8+ pinMode (this ->echo , INPUT);
9+ }
10+ HCSR04::~HCSR04 ()
11+ {
12+ ~this ->out ;
13+ ~this ->echo ;
14+ }
15+ // /////////////////////////////////////////////////dist
16+ float HCSR04::dist () const
17+ {
18+ digitalWrite (this ->out , LOW);
19+ delayMicroseconds (2 );
20+ digitalWrite (this ->out , HIGH);
21+ delayMicroseconds (10 );
22+ digitalWrite (this ->out , LOW);
23+ return pulseIn (this ->echo , HIGH) / 58.0 ;
24+ }
Original file line number Diff line number Diff line change 1+ #include < Arduino.h>
2+ class HCSR04
3+ {
4+ public:
5+ HCSR04 (int out,int echo); // initialisation class HCSR04 (trig pin , echo pin)
6+ ~HCSR04 (); // destructor
7+ float dist () const ; // return curent distance of element 0
8+
9+ private:
10+ int out; // out pin
11+ int echo; // echo pin list
12+ };
You can’t perform that action at this time.
0 commit comments