资源简介
arduino new ping.头文件 arduino new ping.头文件 arduino new ping.头文件
代码片段和文件信息
// ---------------------------------------------------------------------------
// Created by Tim Eckel - teckel@leethost.com
//
// See NewPing.h for license purpose syntax version history links etc.
// ---------------------------------------------------------------------------
#include “NewPing.h“
// ---------------------------------------------------------------------------
// NewPing constructor
// ---------------------------------------------------------------------------
NewPing::NewPing(uint8_t trigger_pin uint8_t echo_pin unsigned int max_cm_distance) {
#if DO_BITWISE == true
_triggerBit = digitalPinToBitMask(trigger_pin); // Get the port register bitmask for the trigger pin.
_echoBit = digitalPinToBitMask(echo_pin); // Get the port register bitmask for the echo pin.
_triggerOutput = portOutputRegister(digitalPinToPort(trigger_pin)); // Get the output port register for the trigger pin.
_echoInput = portInputRegister(digitalPinToPort(echo_pin)); // Get the input port register for the echo pin.
_triggerMode = (uint8_t *) portModeRegister(digitalPinToPort(trigger_pin)); // Get the port mode register for the trigger pin.
#else
_triggerPin = trigger_pin;
_echoPin = echo_pin;
#endif
set_max_distance(max_cm_distance); // Call function to set the max sensor distance.
#if (defined (__arm__) && (defined (TEENSYDUINO) || defined(PARTICLE))) || DO_BITWISE != true
pinMode(echo_pin INPUT); // Set echo pin to input (on Teensy 3.x (ARM) pins default to disabled at least one pinMode() is needed for GPIO mode).
pinMode(trigger_pin OUTPUT); // Set trigger pin to output (on Teensy 3.x (ARM) pins default to disabled at least one pinMode() is needed for GPIO mode).
#endif
#if defined (ARDUINO_AVR_YUN)
pinMode(echo_pin INPUT); // Set echo pin to input for the Arduino Yun not sure why it doesn‘t default this way.
#endif
#if ONE_PIN_ENABLED != true && DO_BITWISE == true
*_triggerMode |= _triggerBit; // Set trigger pin to output.
#endif
}
// ---------------------------------------------------------------------------
// Standard ping methods
// ---------------------------------------------------------------------------
unsigned int NewPing::ping(unsigned int max_cm_distance) {
if (max_cm_distance > 0) set_max_distance(max_cm_distance); // Call function to set a new max sensor distance.
if (!ping_trigger()) return NO_ECHO; // Trigger a ping if it returns false return NO_ECHO to the calling function.
#if URM37_ENABLED == true
#if DO_BITWISE == true
while (!(*_echoInput & _echoBit)) // Wait for the ping echo.
#else
while (!digitalRead(_echoPin)) // Wait for the ping echo.
#endif
if (micros() > _max_time) return NO_ECHO; // Stop the loop and return NO_ECHO (false) if we‘re beyond the set maximum distance.
#else
#if DO_BITWISE == true
while (*_echoInput & _echoBit) // Wait for the ping echo
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-12-11 03:22 NewPing\
目录 0 2016-08-04 06:00 NewPing\examples\
目录 0 2016-08-04 05:55 NewPing\examples\NewPing15SensorsTimer\
文件 4286 2017-12-11 02:48 NewPing\examples\NewPing15SensorsTimer\NewPing15SensorsTimer.pde
目录 0 2016-08-04 05:55 NewPing\examples\NewPing3Sensors\
文件 1066 2016-08-10 07:19 NewPing\examples\NewPing3Sensors\NewPing3Sensors.pde
目录 0 2015-06-01 22:40 NewPing\examples\NewPingEventTimer\
文件 2771 2012-08-29 13:11 NewPing\examples\NewPingEventTimer\NewPingEventTimer.pde
目录 0 2015-06-01 22:40 NewPing\examples\NewPingExample\
文件 1072 2012-08-29 13:10 NewPing\examples\NewPingExample\NewPingExample.pde
目录 0 2016-08-04 05:55 NewPing\examples\NewPingTimerMedian\
文件 3247 2016-08-05 09:42 NewPing\examples\NewPingTimerMedian\NewPingTimerMedian.pde
目录 0 2015-06-01 22:40 NewPing\examples\TimerExample\
文件 1248 2012-06-28 11:17 NewPing\examples\TimerExample\TimerExample.pde
文件 684 2017-12-11 02:29 NewPing\keywords.txt
文件 659 2018-07-16 01:44 NewPing\library.properties
文件 143 2017-12-11 03:26 NewPing\README.md
目录 0 2017-12-11 02:23 NewPing\src\
文件 17523 2017-12-11 02:09 NewPing\src\NewPing.cpp
文件 15592 2018-07-16 01:44 NewPing\src\NewPing.h
- 上一篇:naca翼型生成器
- 下一篇:开启和关闭小键盘的一个小工具
相关资源
- 关于12864显示屏与arduino的连接图
- 基于arduino驱动步进电机旋转魔方的全
- GY530-VL53L0X ARDUINO激光测距代码
- MsTimer2.zip
- Arduino 亚博智能平衡小车源码
- Arduino_Uno-原理图
- flexitimer2库
- Arduino 超声波库函数
- arduino 读取温湿度dht11
- arduino电子时钟
- 人体检测模块
- arduino 原理图 PCB
- DallasTemperature,OneWire库
- DS1302的Arduino函数库
- TB6600步进电机Arduino控制程序
- Arduino UNO引脚分布图
- 气压传感器SDP810的Arduino控制代码
- arduino软串口库文件SoftwareSerial
- Arduino感光灯
- Arduino驱动四线电阻触摸屏代码
- 武术擂台机器人代码arduino
- arduino 5路循迹小车代码
- 基于Arduino的PM2.5和空气湿度检测装置
- 手势识别传感器paj7620 arduino板使用代
- ARDUINO开发板与读卡模块的连接使用
- Face-tracking.zip
- Dht11温湿度模块库文件
- Arduino uno+esp8266+onenet+dht11温湿度传感器
- Arduino与LabVIEW互动设计
- 智能小车超声波避障实验+源码(有舵
评论
共有 条评论