// Bambino // TAB FILE > acts40.ino // ACTS - WanderSteps(steps), Wander() // RightStep(steps), LeftStep(steps) // rock(repeats), shuffle(repeats) // SOUND - whee(), whoa() // beep(byte beeppin,int beepfreqHz,long beeptime) //beeptime in millisecs //== ACTS =================================================== void WanderSteps(int steps) // Wander and avoid for 'repeat' steps { while(steps--) { Wander(); // Wander and avoid } } //---------------------------- void Wander() // Wander and avoid, just one step { readBeard(); queryEdgeLR(); avoidHolesLR(); // if there is a hole then avoid it #ifdef BambinoMM // BambinoMM has no Whiskers #else readWhiskers(); queryObstaclesLR(); avoidObstaclesLR(); // if there is an obstacle then avoid it #endif objectRange =dist_HC_SR04(); avoidUObjects(); // if there is an object then avoid it forward(); speedup(); } //---------------------------- void RightStep(int steps) //turnRight for repeat steps { while(steps--) { turnRight(); } } //---------------------------- void LeftStep(int steps) //turnLeft for repeat steps { while(steps--) { turnLeft(); } } //---------------------------- void rock(int steps) { while(steps--) { rollRight(); rollLeft(); } } //---------------------------- void shuffle(int steps) { while(steps--) { paceRightForward(); paceRightBackward(); } } //== SOUND ================================================== void whee() // make rising sound { for (int i=500; i<5000; i+=100) { beep(voicePin,i,10); } } //---------------------------- void whoa() // make falling sound { for (int i=5000; i>500; i-=100) { beep(voicePin,i,10); } } //----------------------------------------------------------- void beep(byte beeppin,int beepfreqHz,long beeptime) //beeptime in millisecs { int periodus =1000000 /beepfreqHz; long loops =(beeptime *500)/periodus; //if beeptime is not long the sums fail for (int x=0;x