Data Sheet

# finish driving single URM function
# if use the IO expansion shield to drive the urm sensors, the measuring rate may be 20Hz or slower[if
you want].
# The sample code is compatible with the Arduino IDE 1.0 and also the earlier version.
*/
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#define printByte(args) Serial.write(args)
#else
#include "WProgram.h"
#define printByte(args) Serial.print(args,BYTE)
#endif
#define SerialPort Serial
#define urmAccount 1 // Init the account of the URM04 sensor
#define CommMAXRetry 40
#define TriggerPin 2
/******************** Variables ****************/
byte startAddr = 0x11; // Init the URM04 485 Address -- URM04 default address = 0x11
byte readingStep;
byte cmdst[10];
int urmID[urmAccount];
unsigned int urmData[urmAccount];
unsigned long managerTimer = 20;
/******************** Functions ****************/
void urmInit();
void runUrm4();
void urmTrigger(int id);
void urmReader(int id);
void transmitCommands();
void decodeURM4();
void analyzeUrmData(byte cmd[]);
/****************** Init sensor ****************/
void urmInit(){
pinMode(TriggerPin,OUTPUT); // TTL -> RS485 chip driver pin
digitalWrite(TriggerPin,LOW);// Turn the driver pin to LOW -> Turn on reading mode for the RS485
interface
// Turn the drvier pin to HIGH -> Turn on code transmitting mode for the RS485
interface
readingStep = 0;