Library for UltraSonic Distance Sensor.
Follows the MIT license ( Please check LICENSE file for more information. )
- in case of Library file in Arduino/Library folder
#include <UltraSonic.h>- In case of Library file in Source code file
#include <"UltraSonic_Lib/UltraSonic.h">- FOUR PIN TYPE
UltraSonic us_sensor(FOUR_PIN, (int)TRIG, (int)ECHO);
// us_sensor is object name
// pinType = FOUR_PIN (TRIG pin, ECHO pin)- THREE PIN TYPE
UltraSonic us_sensor(THREE_PIN, (int)SIG);
// us_sensor is object name
// pinType = THREE_PIN (only SIG pin)- mesureDist (int ms = 0, int legthType = 1)
float distance = 0;
distance = us_sensor.mesureDist();
//return measured distance value(float type)
distance = us_sensor.mesureDist(1000);
//return and then delay 1000 ms
distance = us_sensor.mesureDist(0 , CM);
//return centimeter type
//legthType = CM = 0, FEET, INCH, MM, METER- distPrint (int ms = 0, int legthType = 1)
Serial.begin(baud_rate);
us_sensor.distPrint();
//print measured distance value
//"distance : (distance value) (legth type)"
us_sensor.distPrint(1000);
//print and then delay 1000 ms
us_sensor.distPrint(0, CM);
//print centimeter type
//"distance : (distance value) CM"- sensing (int legthType)
sensing(legthType);
//Renew distance value inside object-
Supports the sensors below.
HC-SR04(datasheet in /doc/HCSR04.pdf)- all TRIG, ECHO Type UltraSonic Sensor
-
The boards below are supported.
- Test Finished.
Arduino UNOArduino MEGAArduino NANO
- Support Forecast
All boards using Arduino IDE
- Test Finished.
The contents of the example are see Exemples folder.
- 1.0.1
- fix: Change default length type to CM(centimeter)
- 1.0.0
- First official version
- fix: Combine function (distByFloat + distByInt -> mesureDist).
- feat: Add length_type, pin_type.
- 0.0.2 (demo)
- fix: Combine unnecessarily separate function.
- 0.0.1 (demo)
- Start of Develop.
- Register with Library Manager.
- feat: Add distByFloat(),(int ms) / distByInt(),(int ms) / distPrint(),(int ms).
- Jihoon Kim (jihoonkimtech, jihoonkimtech@naver.com)
