www.nexusrobot.com
irqISR(irq4,isr4);
MotorWheel wheel4(10,7,18,19,&irq4);
Omni4WD Omni(&wheel1,&wheel2,&wheel3,&wheel4);
// This will create a Omni4WD object called Omni. then You can use any of its methods;
// for instance, to control a Omni4WD attached to pins, you could write
SONAR sonar11(0x11),sonar12(0x12),sonar13(0x13),sonar14(0x14);
unsigned short distBuf[4];
unsigned char sonarsUpdate() {
static unsigned char sonarCurr = 1;
if(sonarCurr==4) sonarCurr=1;
else ++sonarCurr;
if(sonarCurr==1) {
distBuf[1]=sonar12.getDist();
sonar12.trigger();
} else if(sonarCurr==2) {
distBuf[2]=sonar13.getDist();
sonar13.trigger();
} else if(sonarCurr==3){
distBuf[3]=sonar14.getDist();
sonar14.trigger();
} else {
distBuf[0]=sonar11.getDist();
sonar11.trigger();
}
return sonarCurr;
}
void goAhead(unsigned int speedMMPS){
if(Omni.getCarStat()!=Omni4WD::STAT_ADVANCE) Omni.setCarSlow2Stop(300);
Omni.setCarAdvance(0);
Omni.setCarSpeedMMPS(speedMMPS, 300);
}
void turnLeft(unsigned int speedMMPS){
//SONAR is be defined in <SONAR.h> as a class
// Used to save the data of the 3 sonars return
// A variable save a data used to flag the state of sonar
// The conditions is ture?
// Get the value of distance from sonar12
// Trigger sonar12
// Return the value
// Car moves advance
// If the car's state is not advance.stop it
// else moves advance continue
// Set the car speed at 300
Robot Kits manual
// Software initialization
116
Need help?
Do you have a question about the Nexus Robot and is the answer not in the manual?
Questions and answers