CS 1020 - Lab 2 - Simple programming

In this lab, you will write your first Handy Logo programs. Each of the exercises below requires you to add code to this file. Test your programs by downloading them onto the Handy Board (start HandyLogo, then click the Button labeled "..." and locate your lab2.txt file in your middfiles account).
  1. Ping-Pong Sciborg
    Make sure your Sciborg has front and back bumper sensors. Complete the procedure "ping-pong" to instruct the robot to bounce back and forth between two walls or obstacles.

  2. Escaping from a maze
    Modify your ping-pong strategy to help your Sciborg find its way out of a field of obstacles. For example:

    Implement your strategy by completing the procedure "escape". Hint: there is a built-in procedure "random n" (where n is any integer of your choosing) that returns a random number between 0 and n-1. You might find this useful.

  3. Sensor music (practice with if, ifelse, and, or)
    For the purposes of these next two exercises, do not use the sees-black? procedure - just read and use the sensor values directly.
    1. Complete the procedure "music1" to turn the following algorithm description into a working Logo program that depends on the value of a single analog sensor: If sensor 0 returns a value below 30, play an F note. If its value is between 30 and 130, play a C. If its value is above 130, play an A.

    2. Complete the procedure "music2" to turn the following algorithm description into a working Logo program that depends on the values of two analog sensors: If sensor 0 and sensor 1 both return values over 100, then play a G. Otherwise, if one of them returns a value over 100, play an E. If neither reads over 100, play a C.

    A quick music lesson:

    [note 77 2] plays an F
    [note 84 2] plays a C
    [note 88 2] plays an E
    [note 91 2] plays a G
    [note 93 2] plays an A

Once you are done, add your names and your group number in a comment at the top of your program, and hand in a printout of your program as part of your homework 2 submission on Friday.