www.nexusrobot.com
analogWrite(MOTOR1_E, 48);
analogWrite(MOTOR2_E, 44);
analogWrite(MOTOR3_E, 46);
}
//*************************************************//
void (*motion[8])()={ goAhead,RotateLeft,turnRight,RotateLeft,turnLeft,RotateLeft,judge,allStop};
//change the
void demowithSosars(){
unsigned char sonarcurrent=0;
if(millis()-currMillis>SONAR::duration){
currMillis=millis();
sonarcurrent= sonarUpdate();
}
if(sonarcurrent==3){
unsigned char bitmap = (distBuf[0] < 20);//front
bitmap |= (distBuf[1]<20) <<1;
bitmap |= (distBuf[2]<20) <<2;
Serial.print("bitmap=");
Serial.println(bitmap,DEC);
(*motion[bitmap])();
}
}
//*************************************************//
void setup() {
TCCR1B=TCCR1B&0xf8|0x04;
TCCR2B=TCCR2B&0xf8|0x06;
pinMode(MOTOR1_E, OUTPUT);
pinMode(MOTOR2_E, OUTPUT);
pinMode(MOTOR3_E, OUTPUT);
SONAR::init();
delay(2000);
Serial.begin(19200);
}
void loop(){
demowithSosars();
//delay(200);
}
// stop the motor1
// stop the motor2
// stop the motor3
//judge if the time more than SONAR::duration;
//left
//right
//call the init() from SONAR.h;
//if the requirement was ture call the function;
Robot Kits manual
124
Need help?
Do you have a question about the Nexus Robot and is the answer not in the manual?
Questions and answers