|CSC 161||Grinnell College||Fall, 2011|
|Imperative Problem Solving and Data Structures|
The goal of this lab is to introduce the Scribbler 2 robot to students.
In this lab, you will experiment with the Scribbler 2 robot's sound capabilities, as well as practice writing and compiling programs that use the robot.
For every program using the Scribbler 2 robot, you first must connect
to the robot. At the end of the program, you will disconnect from the
robot. The command to connect to the robot
rConnect("/dev/rfcomm0"); . This opens a connection to
the robot using the port
/dev/rfcomm0 . Later in the lab,
you will experiment with what happens when the port is not included. The
command to disconnect from the robot
rDisconnect(); . Here, you do not need to state any port.
Hint: Don't forget to include the library
MyroC.h at the beginning of every program.
Connecting to and disconnecting from the robot.
In this exercise, you will download the code for a program that
connects to the Scribbler, beeps once, and then disconnects from the
Scribbler. Read the program and its annotations to further understand
what is happening. You will then copy the program to your emacs
file and compile the program on your terminal. Finally you will run the
Here are the steps to do these:
emacs scribblerlab.c &
gcc -lMyroC -o scribblerlab scribblerlab.c
Experimenting with Connections
scribblerlab.c, delete the
/dev/rfcomm0port that is in
rConnect. What happens when you compile and run? Now type
hellointo the port. What happens when you compile and run? Do the same for the null string "" . Replace the port when you are done and save the program.
scribblerlab.c, copy the beep statement and change the frequency to 600, 700, 900, 400, 15000 and 200. Experiment with frequencies. Which frequencies are audible?
Write your own program: Music
Write a program that connects to the robot, makes it beep out a short tune that sounds good to you, and disconnects from the robot.
Hint: The pitches for various notes can be found using Wikipedia or in the example programs for today.
When you have finished this lab, be sure to fill out its evaluation form in the "Lab Evaluation" section for CSC 161 on Pioneer Web.
This document is available on the World Wide Web as
created 13 July 2011 by Dilan Ustek & April O'Neill
last full revision 18 July 2011 by Dilan Ustek & April O'Neill
minor editing 22 August 2011 by Henry M. Waker
|For more information, please contact Henry M. Walker at firstname.lastname@example.org.|