SparkFun will be closed Friday 7/3/2020 for the 4th of July holiday. All orders placed after 2 pm MT on Thursday 7/2/2020 will be shipped out on Monday 7/6/2020. SparkFun Support will also resume on Monday 7/6/2020. Have a safe holiday!
Check out this guest post from SparkFun customer Chris Dunn!
It’s amazing! It’s astounding! It’s MAGIC!
With a wave of your programming wand and a few magic words you can teach Sparkfun’s Simon Says Kit to do MAGIC! I have expanded on the original Simon firmware to incorporate this fun trick. I'll also tell you the secret so you can do the trick with your friends!
My father is a semi-professional Magician. When I was growing up “Don the Magic Man” would often take us to some of the magic shops, notably Lou Tannen’s Magic in New York City. It was there, I believe, that I first saw this small magical black box that had three push buttons and a light on its top. The Magician would offer a participant the opportunity to push a button in hopes of lighting the light, but they never could. On the other hand, the Magician, assisted by whispers from the spirits of the mystical swamis, could predict the future and press the right button to light the light. Given multiple tries, the participant could never light the light, even using the same button the Magician had.
Alas, a good Magician never gives away the secrets, but I was the techie of the family and I finally figured it out. The box was absurdly simple. It was 3 on/off push buttons in series with a battery and bulb. The magical secret was in the Magician’s patter and ability to manipulate the participant into pressing buttons in an order until 2 of the 3 switches were closed and then the Magician pressed the third to light the light.
Over the years I have built various incarnations of this box for fun, and recently wanted to build another. Straight to Sparkfun.com I went to get buttons and a box and parts when I had an epiphany! I was staring at what I needed all in one nice neat package -- the Simon Says PTH kit. Using its four buttons and lights and its Arduino programmable ATmega I could duplicate the trick in it with a tweak of its firmware.
What you will need
You will need the Sparkfun Simon Says PTH kit, a 6 pin male header to add to the board, and the 3.3v FTDI basic breakout so you can reprogram the ATmega of the Simon. You will also need a computer with the Arduino programming software and a copy of my Simon Says MAGIC! firmware from the Github repository. It should be noted my code is built on top of and in addition to the official Sparkfun Simon Says open source code. The Simon will still play Simon Says, my code just adds the MAGIC! mode. Many thanks to the original open source coders and software maintainers.
The program theory is fairly simple. Each button can be thought of as its mechanical counterpart - a push-on push-off switch. The program keeps track of the state of the switches internally. Like the original black button box, pressing each switch turns it on or off. Since the switches were in series, the bulb would only come on when all switches were on.
I emulated this in the code by keeping track of a bit for each button. The program starts with all 4 bits off (0). As buttons are pressed they toggle on (1) or off (0) again. Only when all 4 are on will the last button that was pushed light up. Using the low order bits of the byte, it looks like this B00001111 when all the switches are on. I took things a little further in programming than in the original black box. I added a twist in that while any button is lit, the other 3 dark buttons become inhibited. This prevents the dark buttons from changing state or turning off the lit button’s LED, and helps with the trick as I’ll explain shortly.
I added a fair number of comments to the code to help folks follow along with the logic, but it boils down to this: Build your kit, add the 6 pin header, connect it to the FTDI breakout board and your computer, and load the Simon_Says_MAGIC! firmware into it.
If the Simon kit is powered up normally, it will play its Simon game. If you hold the lower left Blue button while powering up, it will go into MAGIC! mode. All 4 internal switches will be off. As the buttons are pressed, they will toggle on - and if pressed again toggle off. You track in your head the state of the switches. When 3 of the 4 switches are on, pressing the last one that is off will turn it on and light it up. At that point only the lit button can go off and on by pressing it. I added a button “click” sound using the built-in buzzer to help identify when a button is pressed or possibly double bounced. If you don’t want the click sound, you can slide the buzzer switch to off.
Doing the MAGIC!
You, the great and mystical Sparkfaan!, select a friend or participant, and tell them the spirits have given you the gift of seeing into the future to know what button lights the light!
Put the Simon down on a table that you have started in MAGIC! mode. Tell them the mystical spirits have looked into the future and told you which button will light. You are going to give them a chance first to see if they can guess what button lights. Put on a show, wave your hands. Show them you have nothing up your sleeves, talk it up good. Chant some magical words: “Abracadabra! Sim Sim Sala Bim! Princess Twilight Sparkle!” and let them push one of the buttons.
You remember which button they just “turned on” and commiserate with them that “No, sorry, that was not the one. A good guess, but it’s never THAT button!” Tell them they have a 1 in 3 chance now and that the spirits want them to try again. Let them push another button. If they push a different one, you now have 2 switches on, and 2 others off. If they push the same one trying to be cute, you have all 4 off. Make a fuss over them failing to light the light, but that “Here now, there are only 2 buttons left. You have 50/50 odds of being right.” You will give them one more chance. Let them push another button – again, keeping track in your head which switches are on and off. After they push the third button, explain they are having a bad day, or are not in-tune with the spirits, or whatever else befits their failure.
You push the fourth button and it lights up! “See, the spirits told me it was this one!” Now you can show them by pressing the 3 dark buttons that they never light up, tell them that these buttons never work (remember, while the one button is lit, the dark buttons cannot change the state of their switches). Press the lit button a few times and show that it goes on and off with each press.
Now—press the lit button so it is OFF and press one of the other buttons saying that it never does anything! (You have just turned that button off too, so there are 2 on, and 2 off.)
Tell your friend the spirits feel sorry for them and that they will let them light the light. Now that they know which button is the only one that lights up.
Let them press the formerly lit button – which will not come on because you had turned the other button off.
Explain “Aw sorry, that button NEVER works!” and press the button you had turned off, it will light because all 4 switches are back on again and the poor friend will be totally flummoxed!
That is the basic sequence of things, by keeping track of the on and off switches in your head, you will be able to manipulate your friends into presses that will never light the light, but you will know which button will! You can develop a patter where you have turned off 2 or 3 switches, giving your friends multiple opportunities to try again to light the light, you just always take the button that will be the fourth “on”! In case of “oopses”, like a double button press you didn’t catch, or you lose track of which switch is where, you can always fall back to “WAIT! The spirits say the batteries are dying!” or reach up and grab an invisible spirit out of the air and say it was trying to escape from the blue button and you are stuffing it back in - to use some excuse to turn off and back on the Simon power switch while holding the blue button to reset it all.
There are dozens of variations, such as letting one friend light the light, while another can never get it. Just keep track of the on’s and off’s. This is great for kids parties, or winning bar bets.
And when they ask you how you did it, you just reply “It’s MAGIC!”