Creating an Imitation of Memory Game Simon

User Generated

unff_xfn

Engineering

Description

For this assignment your goal is to create an imitation of the famous memory game Simon. The game consists of four colored LEDs and four push buttons. A round in the game consists of the device lighting up the LEDs in a random order. The player must reproduce that order by pressing the buttons associated with the LEDs. As the game progresses, the number of buttons to be pressed increases.

If you haven't played the game before, check this site. (Flash player required)

In the process you will:

  • Review how to interface with push buttons.
  • Review how to debounce a push button.
  • Discover how to play sounds using a piezo buzzer.
  • Make use of arrays to store game data.
  • Make use of control and repetition structures for gameplay.
  • Implement your own LED chaser.
  • Create and make use of functions.

In the end, your system should look like the one presented below.

Simon

Functional Requirements

  • This imitation of Simon does not run forever. You are only required to generate ten rounds.
  • During a round the system must illuminate a number of LEDs. Each LED has an associated sound with it. For instance, in round one the system illuminates the red LED and plays the tone associated with that LED. In round two, the system illuminates two LEDs and plays the tones associated with those LEDs. Make sure to leave a second in between the light up of your LEDs.
  • After illuminating all LEDs for that round, the system must wait for the appropriate amount of button presses. For instance, round one should only accept one button press and round two should accept two button presses. The user's button press will blink the LED once and play its associated tone. If at any point the player pushed a wrong button the game is over. If the player pushed all the buttons in correct order then it's a win.
  • When the player wins (this is by pressing all the buttons correctly), the LEDs must exhibit a chaser or sequencer behavior. This should give the appearance of running lights and should be repeated indefinitely. If you are unsure what sequence to implement, you can check this link for some ideas.
  • Use the buzzer to make a sound when the player presses a button.
  • If the user pressed an incorrect button play an error sound, turn off all the lights, and wait indefinitely.
  • Whether it's a win or a lose the game will only be restarted by pressing the reset button on the Arduino.
  • Make sure that on every game you get a different set of rounds.

Getting Started

  1. Download the starter file set. It will contain the following:
  • SimonStarter.ino
  1. Use your favorite IDE or editor to modify your files.
  2. Make use of the provided variables to complete your program. Add more if you feel you need to store additional data.
  3. Make sure to use functions to avoid repetition of source code.
  4. Add comments!
  5. Compile your program and play.

Technical Requirements

  • You are required to avoid copy-paste repetition of code at all costs. You must use functions, control, and repetition structures to achieve this.
  • You are required to use arrays to store game data.
  • You are required to use constants to avoid magic numbers. You should write code that can easily be extended to accommodate more LEDs.
  • You are required to create the functions digitalReadGeneric(), digitalWriteGeneric(), and pinModeGeneric(). These functions replace the Arduino's digitalRead(), digitalWrite(), and pinMode() respectively. The function prototypes are provided below.
bool digitalReadGeneric(uint8_t pin);
void digitalWriteGeneric(uint8_t pin, bool isOn);
void pinModeGeneric(uint8_t pin, bool isOutput);
  • You are required to create the function delayGeneric(). This function replaces the Arduino's delay(). The function prototype is provided below.
void delayGeneric(unsigned long ms);
  • Create a function of your own to handle the tone playing.
  • Use the following steps to generate the tone for the red LED:
    1. Play 440 Hz for 150ms
    2. Wait for 1136us
    3. Play 440 Hz for 150ms
  • Use the following steps to generate the tone for the yellow LED:
    1. Play 784 Hz for 150ms
    2. Wait for 638us
    3. Play 784 Hz for 150ms
  • Use the following steps to generate the tone for the blue LED:
    1. Play 587 Hz for 150ms
    2. Wait for 851us
    3. Play 587 Hz for 150ms
  • Use the following steps to generate the tone for the green LED:
    1. Play 880 Hz for 150ms
    2. Wait for 568us
    3. Play 880 Hz for 150ms
  • The following steps will generate an error-sound:
    1. Play 250 Hz for 250ms
    2. Wait for 250ms
    3. Play 150 Hz for 250ms

Unformatted Attachment Preview

Rar!0!-Ø tä...ñÄÄÄÄKSxx û »ñÄÕ£a'Å J\SÖÄCTTinkercad/Tremendous Habbi-Jaiks. - Tinkercad - Google Chrome 2021-06-29 12-11-33.mp4 afì ïl àfv@%d%E`TdUÕ©ø: ÕÅ©s>-TnsÙü-Á "âTŮ yã q€vóùIÈ3gAAY%S¥ X ©2ll.Nellº DÊ 9ga" DuZd6+37eÓÀ TkB5%$äGÃIeTVe]« P12,8k ÌJB-`Bà]-OBY, QÔúié^/»şx¥Lº?Í('G.24¥»3}.L3ŁÒFI, Él*æºswõk#9eRz KÊUẾ\pg5éÍT"ã40i«_0U ||n_V&Lü”õigH0%öẽ$ITỈV4 {" âeAIWÉ> KD«Ò Î8Ñ--ä [#CåfN- ÀS_XyéàGba2ºS2 * "fåYSa. 1b i ¢Áa/9Y=íaù [LD/+Mooèöd %æ00 i Aú jóóʻWŮS-€/"$600wO8&°æWica i ñuciêÂAJ9] ÁÂã 2òPolã/ç@“q:11WÔ, 5>Ar!wÙS È#mé“Sc“2é ~ûtNdë”;/"^¿¿gôécØ_@Cs“Kzřó: alézÑq-10ỉff-$\}¿ ¥YkqKmBXt#!-'éõÅ, øõs«òn!Ø 0°=Rh%"7F0¢LÀM,'húg8Efür©VÀ ("ãy #fi+fi VệÊEIẽ “ômí.j-81;+râ«\\"^8) RJvÁ–¥èº ! X/ûJËë uËÅüf 0ínDciYUÝT LÊuÍcÈfl\/be0¢ELÚo , Y#m1}a: Ñ: €91ua qÙẽ}jºuTÖoot-EDM” j SÁôi$ »À [6 .8, ss2"!@10h9ºETYuºc2b/AoĨ»%aºiécI5,72ù!E" £7Ñ9 (%5*D vñs @D$BèfÂS) îÊä
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

View attached explanation and answer. Let me know if you have any questions.
View attached explanation and answer. Let me know if you have any questions.https://drive.google.com/file/d/18TnW3LnRU_bB2e5U0...
View attached explanation and answer. Let me know if you have any questions.

[COURSE_NUMBER, SEMESTER, YEAR]
[YOUR_FIRST_AND_LAST_NAME]
[Section NUMBER]
[Programming Assignment NUMBER]
[Due DATE]

Contents
Introduction ................................................................................................................................ 3
Problem Statement ..................................................................................................................... 3
Implementation ........................................................................ Error! Bookmark not defined.
Test and Results ......................................................................................................................... 4
Conclusion ................................................................................................................................. 5

Creating an Imitation o...


Anonymous
Really helpful material, saved me a great deal of time.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Related Tags