Toys and games, such as the original Simon from Milton
Bradley, have relied on electronics to provide fun and
entertainment to children across the world.
Circuit 2
Arduino Code:
16
Troubleshooting:
Only half the circuit works
If only half of your circuit is working, make sure you added the
additional wire from one ground rail to the other. Remember that
breadboards have two power rails on each side and that these can
be connected, or bussed, together to provide the power to both
sides of the same circuit.
No sound
Once the buzzer is in the breadboard, it's hard to see the legs and
which row they are connected to. If you aren't hearing any sound,
make sure your wires are on the same row as the buzzer legs.
Game is not working
If everything starts up ok, but you're having trouble when it comes
time to play the game, you may have a button or two misplaced.
Pay close attention to which pin is connected to each button, as it
matters which button is pressed when a particular color lights up.
With the circuit complete,
plug the Arduino in to a
power source. Once powered,
the buzzer will beep a few times,
and all four LEDs should begin blinking.
The game begins once you press any of the
four buttons. Once the game has been started, a
random LED will blink. Press the button
associated with that color LED to replicate the
pattern. With a successful guess, the pattern will
repeat, this time adding another random LED. The
player is to follow the pattern for as long as possible,
with each successful guess resulting in an additional
layer of complexity added to the original pattern.
The #define statement is used to create constants in your code. Constants are variables that
will likely only have one value during the lifespan of your code. Thus, you can assign
constants a value, and then use them throughout your code wherever you need them.
Then, if you need to change that value, you only have to change one line instead of going
through all the code to find every instance of that variable.
#define
Code to Note:
Real World Application:
Open Arduino IDE
//
File > Examples > SIK Guide >
Circuit #16
What You Should See:
Bytes are another variable type. In the world of computing, a byte is a chunk of space that
contains 8 bits, and a bit is a single binary value. Binary is another way of counting and uses
only 1's and 0's. So a byte can hold all 1's: 11111111, all 0's: 00000000, or a combination of
the two: 10010110.
byte
IOREF
RES
ET
RESET
7-15V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
7
~6
~5
4
~3
2
1
0
TX
RX
13
3.3V
5V
GND
GND
VIN
A0
A1
A2
A3
A4
A5
POWER
ANALOG IN
DIGIT
AL (PWM~)
ON
ISP
TX
RX
IOREF
RES
ET
RESET
7-15V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
7
~6
~5
4
~3
2
1
0
TX
RX
13
3.3V
5V
GND
GND
VIN
A0
A1
A2
A3
A4
A5
POWER
ANALOG IN
DIGIT
AL (PWM~)
ON
ISP
TX
RX
LEARN. SHARE. HACK.
Page 84
Содержание RedBoard
Страница 13: ...Page 11...