Transition Ideas

I'm making a sort of alternate version of yellow drum machine. It uses the sharp proximity sensor. I was wondering how I would make the robot transition from navigating to playing the drums on the next object it encounters. I was thinking a switch, but that seems to weird. I want it to switch by itself. 

I wander how fritsl got his drum machine to transition.


One would write a series of instructions. These instructions would allow the robot to switch between tasks based on changing variables. A simple example could be:

if variable = predetermined_threashold then do something

Frits has posted on the

Frits has posted on the logic behind his YDM. It looks for stuff to drum on. When it detects an object in range, it “snakes” its way up to it so that it is square (90 degrees, orthagonal, pick your geometrical adjective) to the object. Then it pulls up close enough and starts to play.

He’s got a post on here somewhere about “teaching” your robot, rather than programming it, and he uses the YDM as an example. If programming the “frits” way appeals to you, you should definitely search for that post.

Yeah. I wanted to know how

Yeah. I wanted to know how it switched from navigation mode to snake mode. Still a mystery to me.

During a range test within

During a range test within the ‘Navigator’ routine, range is tested.

if range > 155 then gosub Driveforward…


if dist > 55 then …

goto SnakeStart


Does that help?

Does the range test appear

  1. Does the range test appear after a certain amount of time, or is it at the end of the Navigation routine.


It is all going on at the same time. As the unit navigates, it is also looking for objects. With that, it is not even really looking for objects as much as it is looking for 2 edges and figuring the width between.

I gotta be honest with you, tofu… Based on the nature of your questions, I think this might be something you might want to work up to. This is not really a cut-and-paste kinda operation and it sorta falls into the “you are on step 7 and asking about step 482” catagory…

Sorry. I just got the

Sorry. I just got the navigation of the robot down. So I wanted to work on how it was going to transition form it to drumming.

Object Detection

It stops driving and starts drumming when it finds it’s object.

Edge find left

Edge find right

Calc width

if width >=  threashold then center yourself

recheck distance

close distance

if distance = close_enough_to_drum + or - threashold then drum

drum sequence starts

drum sequence ends

return to main

Thanks! I needed that.

Thanks! I needed that.

Did you not read his code?

You do know that Frits posted all his code, right? You can read the whole thing. Have you finished your edge find routine?

Yeah. But it was too

Yeah. But it was too complicated for me to understand. I have intermediate knowledge of the PICAXE language.


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.

Thanks for the advice. I

Thanks for the advice. I appreciate it. :smiley: