Autonomous Sphero with orbBasic

This is a quick update on my earlier post where I have included orbBasic code for the Orbotix Sphero which will give it some rudimentary autonomy. Observe that the code comments below should not be sent to the Sphero. I am currently working on creating a more user friendly tool for loading basic into the sphero. The undocumented command line tool included in the embryonic framework from my previous post will read an orbBasic file, strip the comments, and transfer it to the Sphero. However, since I only posted source code you will need Visual Studio to compile and run it.

' We set color to green and wait for  
' a small bump to start the program 
' proper.
10 basflg 1
20 RGB 0, 255, 0
30 if accelone < 4000 then goto 30 
' Initializing
40 H = rnd 359
50 D = 1
60 S = rnd 192 + 63
' Set random color
70 RGB rnd 255, rnd 255, rnd 255
' Roll in random direction until 15 
' seconds have passed (to avoid 
' getting stuck after soft collision) 
' or until we hit something.
80 goroll H, S, D
90 timerA = 15000
100 timerB = rnd 1500 + 1500
110 if accelone > 5000 or timerA = 0 then goto 150
120 if timerB > 0 then goto 110
' Every few seconds we randomly 
' adjust our heading somewhat 
' (+/- 15 degrees) and continue.
130 H = (H + rnd 30 - 15) % 360
140 goto 60
' We hit something and perform 
' a hard reverse.
150 H = ((H + 180) % 360)
160 goroll H, 255, 2
170 delay 1000
' Lets take it from the top.
180 goto 60

3 thoughts on “Autonomous Sphero with orbBasic

  1. Very Nice!

    Your program can “Find” my Sphero, but “Connect 0” causes Windows to pop-up an “A Bluetooth devices is trying to connect” message. When I click the bubble, Windows ask “Enter the pairing code for the device”. This same thing happens no matter if I install the Sphero as a Bluetooth device before trying to “Connect” or not. I’ve tried “0000” and any other combination of keys I can think of?

    The same problem occurs when trying to connect to the Sphero using other programs I have looked at, so I know its not an issue with your program. I however hopefully you can help me solve my issue with connecting Sphero via BlueTooth.

    I have installed “32feet.NET”, Windows Firewall is disabled, I can see Sphero installs to a com-port in Device Manager, and I can “Find” the device in you program “Sphero-WGG”, just can’t connect.

    Any Ideas?

      1. I wanted follow up and let you know, the issue is resolved.

        I purchased an new laptop, and the program works as expected. The only thing I can figure is the older Dell d620 Bluetooth adapter did not support communications the Sphero wanted to use?

        Thanks for getting back to me.

        Now to program a Kinect to control the Sphero! ;D

        -Wes

        On Thu, Jan 17, 2013 at 3:47 AM, Thomas Bladh wrote:

        > ** > thomasbladh commented: “I haven’t seen this problem myself but this > site (https://sites.google.com/site/companionballs/faq) suggests using > “1234” as a pairing code. If this doesn’t work I could do a little more > digging.”

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 )

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.