This sketch is missing a short description
1 - * Simon Tilts
* Originally written by Pete Lewis January 2014
* SparkFun Electronics
* Beerware License. Feel free to use/tweak this, but if you meet me at a bar,
* you can buy me a beer.
*
* This code is meant to be used with SFE's Simon Tilts thru-hole soldering kit.
* It can be found here: https://www.sparkfun.com/products/12634
*
* It is an educational kit that is not only meant to teach thru-hole soldering,
* but it also challenges the player to practice memory and orientation skills.
*
* This is intended to create a pattern game, similar to the Simon Says, that
* involves motion. It uses 3 IR tilt sensors to sense the position of the PCB
* in relation to gravity. All 6 sides of the PCB has an LED on it, these are
* used to indicate the next tilt direction of the pattern. The buzzer is also
* used to associate a tone with each position.
*
* To start the game, the user must tilt the PCB in any direction. Then repeat
* the pattern you see. Remember, tilting an LED upward is the equivalent of
* "pressing that button".
2 - randomSeed(analogRead(A7)); // We use random() to create the unique game
// pattern for each level.
// This seed helps make it "more" random
3 - LED SETUP
Turn all six to OUTPUTS
4 - Turn the GND return for all six leds to output, and low
5 - BUZZER SETUP
The Buzzer is connected to pins 12 and 13
Turn both to outputs
6 - pinMode(12,OUTPUT);
pinMode(13,OUTPUT);
pinMode(7, OUTPUT);
7 - if you want to use the tilt sensors and output that data from Simon
8 - Define a function to take a single reading of the tilt sensors
This function will read all three tilt sensors,
and return a byte value that represents the current read position.
Each infrared detectors will output a different voltages depending on where
the BB rests in it's corresponding tilt arm.
If we take an analogRead() on one of the infrared detectors, we can know
if the BB is present or not (that is, blocking the IR emitter).
Through some testing we found that when the BB is at the bottom of the tilt
arm, and blocking the IR, the analogRead will consistently return a value
greater that 875. This is our "threshold" value.
9 -
Embed This Sketch
Use the following HTML code to embed the sketch code above in your blog or website.
<iframe style="height: 510px; width: 100%; margin: 10px 0 10px;" allowTransparency="true" src="https://codebender.cc/embed/sketch:114580" frameborder="0"></iframe>
Embed The Serial Monitor
You can also embed the Serial Monitor section! Just use this HTML code.
<iframe style="height: 510px; width: 100%; margin: 10px 0 10px;" allowTransparency="true" src="https://codebender.cc/embed/serialmonitor" frameborder="0"></iframe>