Introduction to Scribblers and Python
Python is a modern, easy-to-use, full-featured programming language that we will be learning to use by programming scribbler robots. These are simple little “tank” robots that have a number of sensors including a color camera, infrared sensors and light sensors. Our computers will connect to them using bluetooth.
In order to start using your robot, you have to make sure that your bluetooth dongle is connected to the computer with the matching number in the upper right corner of the screen. You also need to make sure the numbers on the robot, green board and dongle match.
Once you are sure all numbers match, you will need to click on the desktop icon that says ‘Python for ROBOTS.’
Once IDLE loads up, type in these commands:
from myro import *
initialize("com3")
Your screen should look like the following:
You should get a popup asking you to accept the bluetooth communication. Click on it:
You should then be asked for a bluetooth passkey. Type in 1234 as follows:
If your screen does not say “Hello, I’m ” and a robot name, you need to update the robot’s software! Run the following command:
>>> upgrade(“scribbler”)
To personalize your robot, you can give it a name. For example, to name a robot “SuperBot”
>>> setName(“SuperBot”)
You are now ready to send commands to your robot! For today, I want us to make sure there are no technical hurdles and then experiment with some of the basic commands. To start, try typing in joyStick() and use the mouse to direct your robot around the room. How far can it get before it is out of range? Make sure you’re doing this on the floor so your bot doesn’t fall off the table!!
Your robot can produce songs! This is going to get pretty annoying, but it’s in the name of learning, right? Each group is going to write a robot song. The basic idea is that you will be using a beep command. Try this:
>>> beep(1, 440)
You should have heard a tone play for 1 second at 440Hz. Hz? Remember frequency? beep is a command that creates waves at specified frequencies. It turns out that 440 is the frequency of an A. Try creating a beep at a higher frequency:
>>> beep(1, 800)
It sounds higher-pitched, right? The human ear can hear roughly between 20 Hz – 20 kHz. Can you hear a beep(1, 20000)? What about beep(1, 20)?
In order to create your song, you will create a new robot command! For example, I will call mine mySong. Here is what my code looks like:
- Notice the red stuff at the top? That’s a comment. Python ignores it, but it’s helpful for lowly humans to know what’s going on! Always put a comment with your names at the top of the file!
- Notice also that all of the statements in the definition of mySong are indented. That’s really important.
- Notice the def keyword. It’s used to define a new command which in Python is called a function. Functions always have parentheses after them.
I encourage you to download robotsong.py (just click on the link at left or on the calendar) and play it yourself. To play the song, go to ‘Run Module’ as follows:
When you are ready to write your own robot song, go to ‘File > New Window’ and get a new program file. Save it using a descriptive name of your choice and make sure it has .py at the end! I highly recommend that you create a folder in your home directory called robot to keep all of your robot files together.
=====
If you get done early, experiment with the following commands:
forward(1, 1)
What do the two numbers in the parentheses seem to represent?
print "Hello"
Can you print numbers?
name = raw_input("What is your name?")
print "Hi", name
Think back to your Scratch experience. What do you think name is?









