A Sphero roadtrip

It was downloading the latest update to the Tickle app application that made me realize that I hadn’t written a program to make my Sphero do something for a while.  A look at the street closings in town for the Santa Claus parade gave me a bit of an inspiration.

  • there are lots of turns to be made
  • there are four stop lights along the main street in town
  • some drivers seem to make random turns at time
  • I wonder if people will end up where they plan as a result

There’s my inspiration.  Sure, I play around with Sphero chasing the dog around the rec room but this would be something that would have a bit of a focus.

So, here’s my program.

2016-11-26_1606

 

The nice thing about Tickle for those of us who grew up on code is that you can actually see the scripting that makes the magic happen.

2016-11-26_1608

Stepping back and going on a tangent here, this introduction illustrates one of my frustration with block programming languages.

I know exactly what I want to make Sphero do.  Chances are, you’re going to have to spend a few moments to figure it out.  I find it frustrating when people demonstrate or students code by going directly to the language and try to make things happen.  I grew up, and I taught my students, about the importance of planning in advance and of the value of internal documentation to a program.  I reminds me of the advice that “if a program was hard to write, it should be harder for others to modify”.  That bit of sarcasm is guaranteed to NOT land you the job.

So, here’s my explanation of the program.

  • I’m going to simulate a stop light for the Sphero movement – Sphero is going to be both car and light.  You’ll start at a red light where Sphero is stopped.  The program makes Sphero turn red accordingly.
  • The red light lasts three seconds.
  • When the light turns green, Sphero will turn green and move.
  • How Sphero moves is dependent of the results of a random number.  If the random number is 1, then Sphero turns right.  If the random number is 2, then Sphero turns left.  If the random number is 3, then Sphero goes straight ahead.
  • The actual movement of Sphero is 2 seconds at a speed of 50% of full.  Truth in numbers – I would need a bigger floor space to make that happen; when playing around with the program, I adjusted these to lower numbers.
  • An amber light signals that Sphero needs to get ready to stop and does.
  • We’ll repeat this for the four stop lights in town.
  • My red lights are three seconds in duration.  That’s totally unrealistic in real life but it seems to take forever when you test it.

And I had a bit of fun playing around while the dog went to another place in the house.

I wonder – how could I make it better?  How about using it to explore things on a road trip or a little question about randomness?

  • What would have to happen for Sphero to go straight through town without making any turns?
  • What would have to happen for Sphero to turn around?  U-turns aren’t legal.
  • Would I end up in the same place every time the program runs?  Of course not – but how many different places could it possibly end?  Could we plot it on a map or chart paper?
  • What would be the scenic highlights of the roadtrip in our town?
  • What would you see if, instead of starting in town, we tracked Sphero’s movement if it started at Yonge and Bloor Streets in Toronto?

I think that questions like this along with the corresponding programming make for a great bit of fun and certainly more understanding.

What would you ask?

5 thoughts on “A Sphero roadtrip

  1. Thanks for the great post, and a reminder, as I prepare to start my students on Scratch, that we will need a reminder that our science/design/creative process rhinking has to apply here, too. What do we want to do, and how can we plan it effectively?

    Like

  2. I want to mention the documentation. I’m learning a new platform, and the code for a longish sample tutorial has example TWO lines of documentation. Some judicious use of comments is always welcome.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s