Simon the Octopus
This project was done for our Things That Think class where we had to make a PlushBot (a plush toy that thinks! “with computation”) thus, kids were our target.
We decided on an octopus that would have all eight arms flashing, however, due to the limited number of pins on the Lilypad Arduino micro-controller, the number of functioning arms were decreased to four.
This project has been done for the Things That Think class at CU Boulder.
– Sewing machine.
– Laser cutter (possibly replaced by precise manual work)
– Lilypad Arduino
– Fennel fabric
– Conductive thread
– Octopus pattern
– 10k Resistors
– Alligator clips (for testing)
Step 1: Design
– The pieces were sewn on the inside using the sewing machine, flipped and then stuffed.
– Arms Wiring:
For each leg there will be 4 wires/threads coming out, 2 for the button and 2 for the light.
For each button one end will go to positive and the other will go to an input pin labeled in the code.
For the lights the negatives will all be pulled to negative and the positive will be pulled to an output pin labeled in the code.
– To avoid the conductive threads crossing (which would cause circuit shorts) we had layers of fabric on the bottom of the Lilypad to separate them.
Step 2: Code
– We used the buzzer, LEDs, and buttons that were included with the lillypad.
In order to get the buzzer to work there are two calls that you need: tone() and noTone().
As a quick note the tone() function interferes with the PWM output on pins 3 and 11 except on the Mega.
The function definition of tone is:
tone(pin, frequency) or tone(pin, frequency, duration)
If the duration is not specified the tone will continue to play until the noTone() function is called
applied to pin. The function definition of noTone() is simply noTone(pin).
You can only play one tone on the pin at a time, this wasn’t an issue for us because
we only used one tone per leg.
Our original idea was to use each leg for a different note in the key of C and have
an entire octive. Unfortunately, we did not use all 8 legs for this but with the
right hardware you would just need to make a few mall changes to the code below
to have that working.
There is a nice header file that is included in the arduino package that defines
all of the frequencies to the corresponding note name. Once this header file is
included all you need to do is call NOTE_C4 to have the buzzer play middle C or
if you need a sharp you just insert ‘S’ between the note name and number i.e.
In our code below you will notice that we are using an analog pin for one of the
leg buttons. We had to do this based on the lillypad layout as well as the total
number of pins we were using. We needed to do a few little hacks to get this to
work as the digital pins you can just check to see if the pin is high or low while
the analog outputs its voltage.
For each leg there is a button and a light. When the button is pressed the assigned
note gets activated through the sound pin and plays through the buzzer as well
as the LED in the leg lighting up.
When you win the first part of the Beatles Octopus’s Garden plays followed by
the letter V. The song was done by placing the notes in an array and looping over
that array when the time is right.
The game is relatively simple. At the start of each cycle we check all of the buttons
to see if any of them are pressed. We did this with calls to digitalRead(). We then ‘loop’
through the buttons and if there is a button that is active we set a variable that
stores the most recent pin. We do just check one after another so if you had pins
1 and 4 pressed at the same time it would set the variable to pin 4.
We then take that information and pass it into a switch statement which activates
the light and sound associated with the button pressed. Because of the way we
set everything up it will not light multiple legs or play multiple sounds. That
would be a nice improvement to this project. If you added 3 buzzers you could
play basic major and minor chords by pressing different legs. This would add a
real time music making aspect to the octopus. Also with 8 legs you have all of
the notes you would need to play basic songs in the key of C.
For the game aspect of the code after each iteration through the main loop we check
that we are in simon mode and that the button state has changed (a button had been
pressed). It checks the button value and compares it to the value saved in an array
that describes the game sequence so far. If the values match it adds a new value
to the end of the sequence and plays the entire updated sequence from the start.
If the values do not match it enters into the ‘You Lose’ loop which plays a loser
light sequence and resets the game.
int mode = 0; //0-Simon … 1-sounds/lights
const int leg0B = A4;
const int leg0L = 13;
const int leg1B = 2;
const int leg1L = 3;
const int leg2B = 12;
const int leg2L = 11;
const int leg3B = 6;
const int leg3L = 7;
const int soundPin = 9;
int buttonState0 = 0;
int buttonState1 = 0;
int buttonState2 = 0;
int buttonState3 = 0;
int pauseBetweenNotes = 300;
int playTime = 500; //when playing the simon sequence
int pinsUsed= 4;
int lastPin = 0;
int currentPin = -1;
int lastLight = 0;
const int maxTurns = 50;
int turn = 0;
int arrayCounter = 0;
const int turnsToWin = 4;
unsigned long loseTime;
unsigned long currentTime;
unsigned long delayAllowed = 10000; //press a button within 4 seconds or you lose
For more detail: Simon the Octopus
JLCPCB – Prototype 10 PCBs for $2 + 2 days Lead Time
China’s Largest PCB Prototype Enterprise, 300,000+ Customers & 10,000+ Online Orders Per Day
Inside a huge PCB factory: https://www.youtube.com/watch?v=_XCznQFV-Mw