I’ve learned some valuable lessons today.
Always save your work.
This is a lesson I had always known, but today I will amend it with some secondary lessons:
- A sketch in Arduino is a temporary file and is not saved, no matter how many times you hit CMD+S.
- If you close the Arduino app, say, to load a new library, this temporary file will be deleted.
- Save your sketch in a new file lest it be deleted.
These are things I wish I had known this morning.
P.S. In case I forget to ask: my question for next week is whether there is an OSX oscilloscope app? If we’re connecting our Arduino for the computer anyways, using a separate device seems a bit redundant unless you need high precision.
Before I get to the story implied in the above lessons, I’ll cover the labs that I did to prepare for my heartbreak.
The first thing I did was connect a button as a digital input, and then I printed to serial to see if it was pressed.
I then connected some LEDs to the same circuit as digital outputs, essentially making the same circuits we did last week, but with the Arduino as middleware in between this time around.
Finally, I connected an actuator to serve as an analog input to turn on an LED, which makes for a bit of a dull video.
I then started working on my project for the week, where I learned some valuable lessons about saving your work. I had the bright idea of a Mario simulator. I hooked up a piezo speaker and a photo resister to my Arduino, with the following idea:
- If the photo resister is uncovered or it’s light out, play the regular Mario theme.
- if the photo resister is covered or it’s dark out, play the underground Mario theme.
- if you transition between either of these states, play the Mario pipe noise.
It took a bit of time, but I more or less got this working. I put in some delays for debugging, and then had the bright idea to use the TimedAction library. A problem I was having was that each song had to finish playing before I switched states, so I thought TimedAction would help with this.
I closed the Arduino app to install TimedAction. I reopened it to see that my program was gone.
Luckily, i hadn’t reset the Arduino itself, so the app sort of still worked on the board itself– though it is marred with delays for debugging. So I do have video evidence of my handiwork.
However, without the source code, I would need to rewrite it completely to refine the code, or to at least remove the delays. I assume the board only stores a compiled version, so to try and retrieve it from there would require decompilation and a bit of trouble.
For now, you can enjoy this video. And until I reset the board, one could also enjoy little Mario tunes on it in person as well.
Subscribe via RSS