... | ... | @@ -57,6 +57,7 @@ |
|
|
> }
|
|
|
>
|
|
|
> ```
|
|
|
> ##### Fig. 1: Main method of the SoundSensorTest program. Used to capture sound readings.
|
|
|
>
|
|
|
> #### Results
|
|
|
>
|
... | ... | @@ -70,7 +71,7 @@ |
|
|
>
|
|
|
> ![P1](http://gitlab.au.dk/uploads/group-22/lego/62d5a5f655/P1.png)
|
|
|
>
|
|
|
> ##### Fig. 1: Picture of the setup. The robot was placed on a table and the phone was pointed towards the robot.
|
|
|
> ##### Fig. 2: Picture of the setup. The robot was placed on a table and the phone was pointed towards the robot.
|
|
|
> After each sensor reading the distance to the phone was increased. The distance was not 100% accurate, but an
|
|
|
> approximation.
|
|
|
>
|
... | ... | @@ -81,7 +82,8 @@ |
|
|
> | 1 | 35 |
|
|
|
> | 2 | 20 |
|
|
|
> | 3 | 15-20 |
|
|
|
> | 4 | 9-11 |
|
|
|
> | 4 | 9-11 |
|
|
|
> ##### Fig. 3: Table of sensor reading.
|
|
|
>
|
|
|
> The table shows the distance between the sound sensor and the sound source and the value read by the sensor.
|
|
|
> We used a phone to play a constant tone at the maximum volume. The highest readings came from the closest distance
|
... | ... | @@ -106,8 +108,8 @@ |
|
|
> which consecutive snaps were made with the fingers. The graph below shows the results:
|
|
|
>
|
|
|
> ![G1](http://gitlab.au.dk/uploads/group-22/lego/093160e740/G1.png)
|
|
|
> Fig. Recording of a sequence of four finger snaps. The graph shows data logged from the NXT while running the
|
|
|
> SoundSampler program.
|
|
|
> ##### Fig. 4 Recording of a sequence of four finger snaps. The graph shows data logged from the NXT while running
|
|
|
> the SoundSampler program.
|
|
|
>
|
|
|
> The graph shows four distinct spikes in the sound level caused by the finger snapping. The spikes peak at 30-50
|
|
|
> (db?) before the sound level goes back to its normal. The background noise measured is about 2-10 (db?).It is
|
... | ... | @@ -131,7 +133,8 @@ |
|
|
> first spike it would drive forward, when it heard the second it would turn left, on the third it would turn right
|
|
|
> and on the fourth it would stop.
|
|
|
>
|
|
|
> [![image alt text](http://img.youtube.com/vi/wlh4UXzuPlk/0.jpg)](http://www.youtube.com/watch?v=wlh4UXzuPlk)
|
|
|
> [![image alt text](http://img.youtube.com/vi/wlh4UXzuPlk/0.jpg)](http://www.youtube.com/watch?v=wlh4UXzuPlk)
|
|
|
> ##### Fig. 5: Video of the clap controlled robot in action.
|
|
|
>
|
|
|
> As every word has its own sound profile It could be interesting to investigate if the robot could interpret and act
|
|
|
> differently on various voice commands. For instance it might be possible for the robot to recognize the difference
|
... | ... | @@ -146,11 +149,11 @@ |
|
|
> used to stop the program. This does not work when the program loops in one of the four inner loops. You can make
|
|
|
> the ESCAPE button always work as a program terminator if you also poll the state of the button in the inner loops.
|
|
|
> But you can also use the ButtonListener mechanism to listen for the ESCAPE button and exit when ESCAPE is pressed.
|
|
|
> A simple example of a ButtonListener can be seen in the leJos tutorial, [4]. Try this in the program.
|
|
|
> A simple example of a ButtonListener can be seen in the leJos tutorial, [ref. 6]. Try this in the program.
|
|
|
>
|
|
|
> #### Plan
|
|
|
>
|
|
|
> To implement the ButtonListener from [4] of the Lab Lesson 3 guide.
|
|
|
> To implement the ButtonListener from [3] of the Lab Lesson 3 guide.
|
|
|
>
|
|
|
> #### Result
|
|
|
>
|
... | ... | @@ -169,7 +172,9 @@ |
|
|
> }
|
|
|
> });
|
|
|
> ```
|
|
|
> In order to make the program terminate we use the S
|
|
|
> In order to make the program terminate we use the System.exit(int code) method with the int code being 0. At first we did not know what the ‘int code’ does, and the API gives no answer. We solved the problem by looking at other code examples on the web [4] and found out that we should use the value ‘0’.
|
|
|
|
|
|
This will make the program terminate no matter where in the loops it is running.
|
|
|
>
|
|
|
> ---
|
|
|
> ## Exercise 5 - Clap Controlled Car
|
... | ... | @@ -281,4 +286,7 @@ |
|
|
>
|
|
|
> Code:
|
|
|
> https://drive.google.com/folderview?id=0B7MCCWb4fFztfkhLdElnem8xclFsLWp1WnVhRGdGU25CbHRUTVRIUDFaSG5tVDdLUXNSQ2M&usp=sharing
|
|
|
> |
|
|
\ No newline at end of file |
|
|
>
|
|
|
> [3] - link til tutorial 4 leJos
|
|
|
>
|
|
|
> [4] [leJos terminate program example:](http://lejos.sourceforge.net/forum/viewtopic.php?t=3267) |
|
|
\ No newline at end of file |