Serial.print("MaxDistance:");
Serial.print(theMaxDistance);
Serial.println("mm");
}
void onSetMaxDistance(byte theAddress, boolean isOperationSuccess)
{
//After setting the Max Distance and getting a reply, this function will ru
n.
//Set the Max Distance can limit the Distance range and speed up the detect
ion.
//TODO write your code here:
Serial.print("Address:");
Serial.println(theAddress);
Serial.print("SetMaxDistance:");
if (isOperationSuccess) {
Serial.println("Success");
}
else{
Serial.println("Failure");
}
}
void onSetBaudrate(byte theAddress, boolean isOperationSuccess)
{
//After setting the Baudrate and getting a reply, this function will run.
//TODO write your code here:
Serial.print("Address:");
Serial.println(theAddress);
Serial.print("SetBaudrate:");
if (isOperationSuccess) {
Serial.println("Success");
}
else{
Serial.println("Failure");
}
}
void onSetAddress(byte theAddress, boolean isOperationSuccess)
{
//After setting the Address and getting a reply, this function will run.
//TODO write your code here:
Serial.print("Address:");
Serial.println(theAddress);
Serial.print("SetAddress:");
if (isOperationSuccess) {
Serial.println("Success");
}
else{
Serial.println("Failure");
}
}
void onWrongStack()
{
//If received wrong command, this function will run.
//TODO write your code here:
Serial.println("WrongStack");
}
//Run the proper function based on the different kinds of states
void commandProcess()
{
if (urm.available()) {
switch (urm.callBackState) {
case URM_RS485::OnTimeOut:
onTimeOut();
break;
case URM_RS485::OnRequestDistance:
onRequestDistance(urm.receivedAddress, urm.receivedContent);
break;
case URM_RS485::OnRequestTemperature:
onRequestTemperature(urm.receivedAddress, urm.receivedContent/10.0);
break;
case URM_RS485::OnRequestMaxDistance:
onRequestMaxDistance(urm.receivedAddress, urm.receivedContent);
break;
case URM_RS485::OnSetMaxDistance:
onSetMaxDistance(urm.receivedAddress, urm.receivedContent);
break;
case URM_RS485::OnSetBaudrate:
onSetBaudrate(urm.receivedAddress, urm.receivedContent);
break;
case URM_RS485::OnSetAddress:
onSetAddress(urm.receivedAddress, urm.receivedContent);
break;
case URM_RS485::OnWrongStack:
onWrongStack();
break;
default:
break;
}
}
}
// Add setup code
void setup()
{
urm.begin(DefaultBaudrate);
}
// Add loop code
void loop()
{
commandProcess();
static unsigned long sendingTimer=millis();

SEN0149

Mfr. #:
Manufacturer:
DFRobot
Description:
Distance Sensor Modules URM06 - RS485 Ultrasonic
Lifecycle:
New from this manufacturer.
Delivery:
DHL FedEx Ups TNT EMS
Payment:
T/T Paypal Visa MoneyGram Western Union

Products related to this Datasheet