Step 1: Determine light sensor threshold values
Open the Sandbox project, create a Scribbler object and connect it to your robot, then invoke the senses method. Experiment to find out what value the light sensors return when the sensor is covered. This will be the threshold value used in later steps. When you.re finished with this step be sure to close the connection by invoking the close method. You can close the Sandbox project.
Step 2: Dimming the Lights
Create a new project and create a class named LightDimmer. This program will behave as follows:
Connect to the Scribbler For 30 seconds do the following: read the left and right light sensors if both left and right sensors are covered set the Fluke back LED to 0.1 turn on the left and right Scribbler LEDs else if the left sensor is covered and the right is not covered set the Fluke back LED to 0.2 turn the left Scribbler LED on and turn the right LED off else if the left sensor is uncovered and the right sensor is covered set the Fluke back LED to 0.5 turn the left Scribbler LED off and turn the right LED on else set the Fluke back LED to 1.0 turn off both Scribbler LEDs Set the Fluke back LED to 0.0 Turn off both Scribbler LEDs Close the connection to the Scribbler
Step 3: Electronic Flute
Create a class named Flute in you project (or, if desired, you can make a new method inside your existing class). When the main method in this class is started, it should run for 30 seconds and use the values of the three light sensors to play a tone for half a second based on which sensors are covered. The following table lists the tones to be played:
Left
|
Center
|
Right
|
Tone
|
covered | covered | covered | 440 |
covered | covered | uncovered | 494 |
covered | uncovered | covered | 554 |
covered | uncovered | uncovered | 588 |
uncovered | covered | covered | 659 |
uncovered | covered | uncovered | 740 |
uncovered | uncovered | covered | 831 |
uncovered | uncovered | uncovered | 880 |
Submit your java code via moodle.
Additional Challenges
Instead of playing the notes as the light sensors are covered, figure out how to record the user's notes and play them back after the "recording" is finished. You may want to limit yourself to 5 or 10 seconds, rather than 30. Then, once you've made a recording, you should be able to play it back multiple times, depending on the user's choice.