Simon Says - Creation Crate lesson 2
If you grew up in the 80's or 90's I'm betting you've seen one of these before.
Originally released in 1978, this obnoxious toy blinked its way into the homes of every childhood friend I ever had. I once used one in a science fair project to test if memory and reflexes were diminished by staying up all night. Spoiler alert, they were. But this is, at it's heart, a very simple electronic device. Four buttons and four associated lights blink in a random pattern, accompanied by an obnoxious buzzing at different pitches for each color. The player has to repeat the pattern in a specified amount of time. With each correct response, the pattern grows in length until you reach a predetermined length, or lose. Most of the time I lost.
The goal of the second month creation crate was to recreate this toy on a breadboard using an arduino uno. This I did with some success.
Following the diagram to build the electronics was very easy. I understood right away how to connect the buttons and the lights to the arduino in a way that would allow me to control them. The piezo buzzer (the little black circular thing on the left) was a new component for me, but it has a long and a short lead, just like an LED, and I didn't have any trouble understanding how to hook it up either. When it came to writing the code, that's where things got tricky.
I began this endeavor because I wanted to learn how to write code for arduino. Having had no formal training in programing, I was forced to rely on my programing husband or on purchasing products or code from other individuals in order to add electronic props to my escape rooms. I have always been very strongly self reliant, and I HATE that there is a part of my business that I simply... can't do.
The creation crate has been fabulous at explaining how the electronic circuits are built and how they function and how the electricity flows through components to make things happen. It offers very little in the way of explaining the code. It makes me feel like the product is a toy, rather than the ability to build the toy. Essentially, it offers the code up and you copy it line by line. There are several comments in the code to explain what each line of code does, but there's nothing really that explains how to write the code if you were doing it from scratch. It's not that they don't try at all, the comments are there, and there are several challenges at the end of the project that tell you to change this thing or that thing in the code to make something different happen. For example, in this project, I changed the speed factor to make the pattern slower or faster, I changed the tones that the buzzer makes, and I made the LEDs blink three times instead of two when you lose.
Perhaps I'm just an impatient demanding woman, but that isn't enough for me. I want to understand how to write a program from scratch. I want to plan out a puzzle in my escape room, and then sit down and write the code for it. And without supplementation, this monthly crate would not accomplish that.
I have some specific complaints. The comments are not consistently in the same place. In some instances, the comments describing the code are before the lines of code. In others, they are after. For new learners, consistency is imperative. Also, the code was broken up in a way that didn't make sense. The setup function should be in a separate section to emphasize that it's a separate function that runs once when you power up the device. The declaration of the constants should also be all together in one section, and the loop function should be in a separate section. But the sections are divided up based on the volume of text instead of the content of that text. Dividing them by content would reinforce the concept of three separate parts of the code. Any additional functions should be in their own separate sections as well. And I would very much prefer that there was a video that explained an overview of the code, what it did, and how it did what it does before the code is given out line by line, much the same way they show a video of the hardware and how it works and how it is put together before showing the step by step process and diagrams for you to follow along with. There are also two sets of numbered "steps," one in the code and one on the website - and they don't match. When you read on the website "step three - setup and loop/modes and arrays" and then immediately underneath in the code it says "step four - initialize the inputs/outputs" that's confusing. And unnecessary.
Whoever designed the programing portion of these lessons was not an educator.
In the end, I was able to create a simon puzzle that worked. I did have two issues, one was a typo in the duration of the button and light sequence, which resulted in an unplayable game until I found it. I had put a 100 where there should have been a 1000. And the second was that I had failed to initialize the pin for the buzzer as an output, so the buzzer did not work until I found and fixed that error. Which involved looking at the code line by line side by side with their completed code until I found the differences.
I felt a bit unsatisfied once I was done, because I essentially copied someone else's code. I didn't feel like I wrote anything, despite the small changes I made to make it work differently. So my husband wrote a challenge of his own. He had me write a program, from scratch, to light up the LEDs in sequence. It's a very simple task, but I had to go through the process of setting up the LED pins as outputs, designing a for loop, and writing the code. From scratch. And it worked. I was even able to write code to make the LEDs light up in the opposite order. As simple as that was, it was very satisfying, and make me feel like I had actually learned some coding.
So while I have my complaints, I'm apparently getting more out of this than I perceive. My next challenge, now that I know how to program the arduino to detect button pushes and light up LEDs, is to create a simple four button puzzle where the player has to push four buttons in a specific order. When they do, it unlocks a mag lock. That's really quite simple, but I can take it directly to an escape room and install it. In fact, we have a couple of puzzles exactly like that already. We'll see if I can manage to do that before the next creation crate arrives.