Manual
www.nexusrobot.com Robot Kits manual 
  94
SONAR sonar11(0x11),sonar12(0x12),sonar13(0x13),sonar14(0x14),sonar15(0x15),sonar16(0x16); 
// Software initialization   
//SONAR is be defined in <SONAR.h> as a class 
unsigned short distBuf[6];            // Used to save the data of the 6 sonars return; 
void sonarsUpdate() { 
 static unsigned char sonarCurr=1; // A variable save a data used to flag the current of sonar 
 if(sonarCurr==3) sonarCurr=1; 
 else ++sonarCurr; 
 if(sonarCurr==1) {     // The conditions is ture? 
 distBuf[1]=sonar12.getDist();       // Get the value of distance from sonar12   
 distBuf[4]=sonar15.getDist(); 
 sonar11.trigger(); // Trigger sonar11 
 sonar14.trigger(); 
 } else if(sonarCurr==2) { 
 distBuf[2]=sonar13.getDist(); 
 distBuf[5]=sonar16.getDist(); 
 sonar12.trigger(); 
 sonar15.trigger(); 
 } else { 
 distBuf[0]=sonar11.getDist(); 
 distBuf[3]=sonar14.getDist(); 
 sonar13.trigger(); 
 sonar16.trigger(); 
 } 
} 
/*********************************************/ 
/*********************************************/ 
unsigned char IRpin[]={16,17,18}; // Pin16, Pin17, Pin18 
bool IRs[3]={false,false,false}; 
void initIRs() { // Initial the Pin mode 
 pinMode(IRpin[0],INPUT); 
 pinMode(IRpin[1],INPUT); 
 pinMode(IRpin[2],INPUT); 
} 










