Yeah…
Look, I don’t want to be all negitive-Nelly here but, well…
I say this just so you don’t again fall into the catagory of “on step 7, asking about step 47” thing. The question “how does it transition” shows that it is not an issue of knowledge of code but more of a big picture kinda thing. Not to mention, you will not need to “transistion” untill you have finished many, many, many tests of individual sub-routines.
Here is my advice:
Code what I have written below. Get each section working. Think about how each section (subroutine) will eventually need to “talk” to the others. Don’t reuse bits and bytes so you can put them together easier. Ok. Code each of these. Lable them well. Keep them all in a folder so later you can just open them and cut and paste.
Drive -Fwd, rev, spinr, spinl, slider, slide, encoder turnr, encoder turnl, encoder fwd and encoder rev (if you have encoders)
IR Sharp -simple test with debug. Get a tape measure and a “target”. Measure, check the debug. Write these #s down on paper
Write simple navigation code to avoid obsticles.
Write routine to find the L edge and R edge of an object. Calculate width from servopos1-servopos2. Debug this. On paper, write down what numbers correspond to the widths and distance from various objects.
Add to edge find code -if width is big enough turn on a led for 2 seconds. Move your robot around with your hand to see if the robot can actually “find” an object. Use the LED to debug Fix any problems
Go back to main drive code, cut and paste into a new program. Open up your edge find code and paste it in too. Put them together .Now, figure out how to “snake” to center.
Add to snake to center code. --After snaking, recheck edges and confirm center. If this is all good, turn on a LED for 2 seconds. Now let it find objects. Use the led to debug. Do this over and over and fix errors.
Add to snake to center code (w/ led) --Change the “led on” to let bit?=1. This is the “i found an object” bit to be used in other parts of the main loop
Save and forget about the snake code.
Write simple code to move drum sticks. Grab a metranome and a lot of time, figure out how pauses work, how to use bits to turn sticks on and off, figure in loops and for/next’s. This will take a long time. Look at frits’s code, I am not sure how he did this. A few other people have posted thier code as well as spreadsheets showing thier timing, beats etc.
Save the beat routine.
Get your sound record module. Learn it’s serial or i2c commands. Again, write simple codes for start record, stop and playback.
Add the sound record code to the beat routine. Again, this will take forever to sync everything I would assume.
Go back to edgefind/ object find code. Kinda easy now… Main loop --If bit?=1 then gosub beatroutine. Test this over and over.
Go back to main naviagation code. Add in edge find/ object find code. Now it’s flow chart time --WITH A PENCIL AND PAPER!!! Draw out your flow-chart. When does it look for objects? Does it stop and do a 360 looking every 20 degrees or so? Does it calculate objects during it’s normal sharp sweep? What ever. Figure this out.
And here, my friend. Right here, this is where the “transistion happens”!!! You get to decide! When you have all the sub-systems working it is now time to put them together. And I promise you, after you finish all that coding of all the sub-systems, you will have no need to ask “How does the transistion work?”.
Remember, he wasn’t actually waxing the car, just to learn how to wax a car. He didn’t sand the deck to learn how to sand decks. He did not paint the fence to learn how to paint the fence.