Manual
www.nexusrobot.com Robot Kits manual 
  29
Simple code: 
#include <SONAR.h>    //used the library of SONAR 
// The sonar whose address is 0x11 was named S11, and it was setted as the type of SONAR 
SONAR s11=SONAR(0x11);   
//SONAR s12(0x12); 
void setup() { 
 SONAR::init(); //set up some parameters 
 delay(100);       //100 millissecond   
 s11.setAddr(0x11);   //set address for S11with 0x11 . 
} 
//Ttrigger sonar and display the data. 
void loop() { 
 s11.trigger(); //Send the trigger command to trigger S11 
 //s12.trigger(); 
 delay(SONAR::duration);      //60 millissecond. 
Serial.println(s11.getDist(),DEC);  //Display the distance S11 received. 
s11.showDat();    //Display the data S11 received 
 //Serial.println(s12.getDist(),DEC); 
 Serial.println(s11.getTemp(),DEC); //Display the temperature S11 received 
 //Serial.println(s12.getTemp(),DEC); 
 delay(500); 
} 
¾  Sensor Connection 
As the sensor uses RS485 interface which can not be connected directly to the MCU, a MAX485 chip will 
bridge the TTL interface to RS485. 
For PC users, either a USB-RS485 or RS232-RS485 converter will bridge the gap. 
¾  Sensor Networking 
Up to 32 units are able to join a RS485 network. Simply serially connect the sensors uses twisted pair 
cables. 










