Bonus Lab

This Bonus Section of Lab 6 is here to help you gain back points that you may have lost in previous labs. If you already have a nearly perfect lab score, then I would recommend you skip this Bonus Lab since your lab grade cannot go over 100%.

This Bonus Lab includes four (4) bonus sections to help you win back points.

Table of Contents

Turning Corners (1 point)

Modify isHallway to not only return true if the bear is in a hallway, but also if the bear is in a corner room. Specifically, the bear must turn left (0011, 1100), or right (0101, 1010). When completed the bear should now not only walk down hallways but turn corners. The bear should still stop walking when a decision needs to be made or a room has bees.

Light Show (1 to 2 points)

Have your 8 LEDs put on a light show. For example a Night Rider scanner (1 point) or a random Blinking Light Unit (BLU). See the ShiftOut16.ino program for an example of a nice light show.

Congratulatory Tune (3 to 8 points)

In this bonus part of the Lab you are going to add a fun twist to the maze by teaching your program how to play a congratulatory song snip-it (ta-da) when the bear enters the forest and how to play a sad tune when he is lost in the maze (needs to turn around).

The arduino-proto-shield schematic found in the reference folder includes a simple speaker circuit for you to build. To connect your speaker to the Q output of the D flip-flop, solder a 1×1 .100mm female connector to JP16 as shown here.

To provide power (+5 v) to your speaker circuit, solder a 1×2 .100mm female connector to the first row of pins on the JP9 connector as shown here.

Please ask me if you have any questions.

In order to control the pitch and duration of each note you will need to use two timers. Do not forget that the D-flip-flop will divide your output frequency by a factor of 2. You may not duplicate a song snip-it done by another student or group. See me if you are not sure and most of all have fun.

note frequency
C3 261.6
D3 293.7
E3 329.6
F3 349.2
G3 392
A4 440
B4 493.9
C4 523.3

For more ideas on how to make a higher fidelity version read “Arduino Zero Simple audio player.”

Bonus Points

The number of points awarded will be based on the number of milestones completed successfully. Here is my list of milestones that you may want to achieve and simply stop when you run out of time.

  1. Congratulatory tone (single note) sounds when the bear enters the forest.
  2. Congratulatory song snip-it (ta-da) plays when the bear enters the forest.
  3. Sad tune plays when the bear is lost.
  4. Congratulatory song plays when bear enters the room corresponding to your target square.
  5. Congratulatory song plays (for example the theme from Star Wars) when bear leaves the maze and enters the forest.
    a. Have the bear make snoring sounds before finally putting the microcontroller to sleep.

Write Your Own Bonus Code

Be creative and earn even more bonus points. Check with me before you go too crazy with this section.

Student Hall of Fame

  • Use 8 discrete red LEDs to sequentially display all the flash program words in your program (hint: use the lpm instruction).
  • Use 8 discrete red LEDs and persistence of vision to display the number of bees. In this version the number 16 was displayed including the serif on the 1 and the rounded 6. To view the number you move the proto-shield horizontally at a fixed frequency (quick retrace). Example is included in the Sample Labs folder.