资源简介
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翼型生成器
- 下一篇:开启和关闭小键盘的一个小工具
相关资源
- ADNS-3080光流传感器测试程序Arduino
- EESkill NRF24L01 无线模块用户手册
- Arduino nano 工程文件
- Arduino教程 Lesson 之--自制风扇
- 基于Arduino的智能环境监控系统设计
- 基于Arduino和Machtalk的温棚环境监测系
- arduino pca9685多舵机同时控制案例
- arduino技术内幕
- Arduino电子设计实战指南.零基础篇_超
- 物联网智能家居平台DIY:ARDUINO 物联网
- 实验1.zip arduino跑马灯led灯实验,串口
- opencat所有资料.zip
- arduino主机,stm8从机。I2C测试 。每次
- DS18B20_Serial_println.ino
- ps2手柄arduino库文件
- 基于手机蓝牙的arduino遥控小车
- arduino中的can库函数
- 密码+指纹锁资料包.rar
- 贝壳物联arduino esp8266 demo版本
- HMC5883L罗盘指南针模块库文件及中英文
- arduino 小贱钟源码及教程
- Atom-TMC2208Pilot在Arduino上运行的应用程
- 写字机制作方案
- PID-增量式PID和位置式PID算法实现和
- Building Wireless Sensor Networks Using Arduin
- vc控制Arduino,实现串口通信
- Arduino入门经典
- Arduino所有库.zip
- 基于STM32和arduino的MPU9250九轴传感器代
- GY-9960模块Keil 和Arduino驱动程序
评论
共有 条评论