Improved 'Simon Says' Code

by RonM9 in Circuits > Software

6750 Views, 12 Favorites, 0 Comments

Improved 'Simon Says' Code

Simon_WBe_box_lit.jpg

An updated 'Simple Simon' project.

Specifically, easier to work with software implementation.

Getting Started

Simon_WBe_box.jpg

I started with the instructable at 'Simple-Simon-Says-Game'

Refer to it for general hardware implementation.

As I already had done a project of my own which had 4 buttons, 4 LEDs and a speaker, I used that hardware (seen above). I touched up the photos a little to change some aspects to be more appropriate for illustration in this project.

It uses an Nano 3.0 and I used different pin assignments for the peripherals.

By the way, you may also be interested in a hardware simplified version I did Instructables.com/id/Fast-Easy-Simon

Adapting to New Hardware

The Simon_Says sketch did not work for me as the code relied on fix pin assignments. Further the code was hard to follow and had some bugs.

So I created this updated version.

  • Fixed the miss use of type 'boolean' for pin numbers
  • Modified the code so that it will work for any LED & button pin assignments.
  • The logic flow was overly complicated and in spots too repetitive, causing it to be hard to understand and debug. So I simplified it for the most part.
  • Along with other improvements like the fact that I changed the 'Tone' class object's name from 'speakerpin' to 'speaker' and created a byte variable 'speakerpin' for its pin # assignment.
  • Oct 2015: allowed for fast button input sequences
  • Aug 2021: Made start pattern real world random

A download link for my updated sketch is included here. You should find it easy to get going with your own hardware by simply changing pin assignments near the beginning of the code. Download and have fun with it.

I have also created a related Tinkercad Simulation.

Now (Dec 2023) there is a new simulation which is smother with better audio on Wokwi.com

Downloads

By Popular Demand

As there has been queries about how to use the software with a servo to operate a latch when a successful set of Simon pattern matching is done. I am including here versions of 'Simon_Says' as well as the similar 'Simon_Sings' which I adapted to be suitable for further modification with appropriate servo code. I have placed '@TODO' comments in the code of each showing where to put one's servo code.There is also an include file they rely on 'toneNotes.h'

As of Aug 2021 'Simon_Says_Open' (v2) no longer uses the 'Tone' object library, which conflicted with the Servo library.

The exact coding will be dependent on the hardware implementation and the servo library one uses. I do not have answers for servo particular issues. For that, I recommend reviewing the likes of the following:
video: How to control servos
instructables.com/id/Arduino-Servo-Motors/
instructables.com/id/Access-control-with-Arduino-Keypad-4x4-Servo/
For those needing further servo related help, I recommend a post to the servo related instructable with the most similarities to their servo implementation.