Data Sheet
startAddr = 0x11;
managerTimer = millis();
for(int i = 0 ;i < urmAccount; i ++){ //Init the URM04 command receiving address
urmID[i] = startAddr + i;
urmData[i] = 0;
}
SerialPort.begin(19200); // Init the RS485 interface
// Also when you are driving the URM04, you could open serial monitor to
// tracing the steps and data feedback from URM04
SerialPort.println();
SerialPort.print("The URM ID: 0x");
for(int i = 0 ;i < urmAccount; i ++){ //Init the URM04 command receiving address
SerialPort.print(urmID[i],HEX);
SerialPort.print(" ");
}
SerialPort.println(" ");
SerialPort.println("The default baudrate: 19200");
SerialPort.println("Start drive the sensors!");
for(int i = 0 ;i < 10; i++) cmdst[i] = 0; //init the URM04 protocol
cmdst[0]=0x55;
cmdst[1]=0xaa;
}
/********************* Drive URM04 and get the data code *************************/
void runUrm4(){ // You could adjust the sensor measuring rate by changing the
managerTimer value
static unsigned long timer = 0;
static int num = 0; //Set the URM04 id to be drived
if(millis() - timer > managerTimer){
digitalWrite(TriggerPin, HIGH); //Turn on transmitting mode for the RS485 interface
switch(readingStep){
case 0:
urmTrigger(urmID[num]);
managerTimer = 40; //set a interval after trigger the measuring
break;
case 1:
urmReader(urmID[num]);
managerTimer = 0; //set a interval after transmitting the reading distance command
break;
case 2: