// # Version : 0.2
// # Description:
// # The Sketch for scanning 180 degree area 4-500cm detecting range
// # Connection:
// # Pin 1 VCC (URM V3.2) -> VCC (Arduino)
// # Pin 2 GND (URM V3.2) -> GND (Arduino)
// # Pin 4 PWM (URM V3.2) -> Pin 3 (Arduino)
// # Pin 6 COMP/TRIG (URM V3.2) -> Pin 5 (Arduino)
// # Pin mode: PWM
// # Working Mode: PWM passive control mode.
// # If it is your first time to use it,please make sure the two jumpers to t
he right hand
// # side of the device are set to TTL mode. You'll also find a secondary jum
per on
// # the left hand side, you must break this connection or you may damage you
r device.
#include <Servo.h> // Include Servo library
Servo myservo; // create servo object to
control a servo
int pos=0; // variable to store the
servo position
int URPWM=3; // PWM Output 0-25000us,e
very 50us represent 1cm
int URTRIG=5; // PWM trigger pin
boolean up=true; // create a boolean varia
ble
unsigned long time; // create a time variable
unsigned long urmTimer = 0; // timer for managing th
e sensor reading flash rate
unsigned int Distance=0;
uint8_t EnPwmCmd[4]={0x44,0x22,0xbb,0x01}; // distance measure comma
nd