change template
This commit is contained in:
parent
29a9cf7015
commit
9da3acb74f
11
.vscode/extensions.json
vendored
11
.vscode/extensions.json
vendored
@ -1,11 +0,0 @@
|
||||
{
|
||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||
// for the documentation about the extensions.json format
|
||||
"recommendations": [
|
||||
"Wokwi.wokwi-vscode",
|
||||
"platformio.platformio-ide"
|
||||
],
|
||||
"unwantedRecommendations": [
|
||||
"ms-vscode.cpptools-extension-pack"
|
||||
]
|
||||
}
|
44
.vscode/launch.json
vendored
44
.vscode/launch.json
vendored
@ -1,44 +0,0 @@
|
||||
// AUTOMATICALLY GENERATED FILE. PLEASE DO NOT MODIFY IT MANUALLY
|
||||
//
|
||||
// PIO Unified Debugger
|
||||
//
|
||||
// Documentation: https://docs.platformio.org/page/plus/debugging.html
|
||||
// Configuration: https://docs.platformio.org/page/projectconf/section_env_debug.html
|
||||
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "platformio-debug",
|
||||
"request": "launch",
|
||||
"name": "PIO Debug",
|
||||
"executable": "C:/p/arduino-simon-game/.pio/build/uno/firmware.elf",
|
||||
"projectEnvName": "uno",
|
||||
"toolchainBinDir": "C:/Users/Uri/.platformio/packages/toolchain-atmelavr/bin",
|
||||
"internalConsoleOptions": "openOnSessionStart",
|
||||
"preLaunchTask": {
|
||||
"type": "PlatformIO",
|
||||
"task": "Pre-Debug"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "platformio-debug",
|
||||
"request": "launch",
|
||||
"name": "PIO Debug (skip Pre-Debug)",
|
||||
"executable": "C:/p/arduino-simon-game/.pio/build/uno/firmware.elf",
|
||||
"projectEnvName": "uno",
|
||||
"toolchainBinDir": "C:/Users/Uri/.platformio/packages/toolchain-atmelavr/bin",
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
},
|
||||
{
|
||||
"type": "platformio-debug",
|
||||
"request": "launch",
|
||||
"name": "PIO Debug (without uploading)",
|
||||
"executable": "C:/p/arduino-simon-game/.pio/build/uno/firmware.elf",
|
||||
"projectEnvName": "uno",
|
||||
"toolchainBinDir": "C:/Users/Uri/.platformio/packages/toolchain-atmelavr/bin",
|
||||
"internalConsoleOptions": "openOnSessionStart",
|
||||
"loadMode": "manual"
|
||||
}
|
||||
]
|
||||
}
|
146
diagram.json
146
diagram.json
@ -1,133 +1,29 @@
|
||||
{
|
||||
"version": 1,
|
||||
"author": "Uri Shaked",
|
||||
"author": "Anonymous maker",
|
||||
"editor": "wokwi",
|
||||
"parts": [
|
||||
{ "type": "wokwi-arduino-uno", "id": "uno", "top": 183, "left": 18.6, "attrs": {} },
|
||||
{ "type": "wokwi-breadboard", "id": "bb1", "top": -12.6, "left": 214, "attrs": {} },
|
||||
{ "type": "wokwi-arduino-uno", "id": "uno", "top": -9, "left": -58.2, "attrs": {} },
|
||||
{ "type": "wokwi-led", "id": "led1", "top": 102, "left": 263, "attrs": { "color": "red" } },
|
||||
{
|
||||
"type": "wokwi-buzzer",
|
||||
"id": "buzzer",
|
||||
"top": 16,
|
||||
"left": 124,
|
||||
"attrs": { "volume": "0.1" }
|
||||
},
|
||||
{ "type": "wokwi-led", "id": "led-red", "top": 10, "left": 6, "attrs": { "color": "red" } },
|
||||
{
|
||||
"type": "wokwi-led",
|
||||
"id": "led-green",
|
||||
"top": 73,
|
||||
"left": 6,
|
||||
"attrs": { "color": "green" }
|
||||
},
|
||||
{
|
||||
"type": "wokwi-led",
|
||||
"id": "led-blue",
|
||||
"top": 10,
|
||||
"left": 270,
|
||||
"attrs": { "color": "blue" }
|
||||
},
|
||||
{
|
||||
"type": "wokwi-led",
|
||||
"id": "led-yellow",
|
||||
"top": 73,
|
||||
"left": 270,
|
||||
"attrs": { "color": "yellow" }
|
||||
},
|
||||
{
|
||||
"type": "wokwi-pushbutton",
|
||||
"id": "btn-red",
|
||||
"top": 10,
|
||||
"left": 46,
|
||||
"attrs": { "color": "red", "key": "1", "label": "1" }
|
||||
},
|
||||
{
|
||||
"type": "wokwi-pushbutton",
|
||||
"id": "btn-green",
|
||||
"top": 76,
|
||||
"left": 46,
|
||||
"attrs": { "color": "green", "key": "2", "label": "2" }
|
||||
},
|
||||
{
|
||||
"type": "wokwi-pushbutton",
|
||||
"id": "btn-blue",
|
||||
"top": 10,
|
||||
"left": 200,
|
||||
"attrs": { "color": "blue", "key": "3", "label": "3" }
|
||||
},
|
||||
{
|
||||
"type": "wokwi-pushbutton",
|
||||
"id": "btn-yellow",
|
||||
"top": 76,
|
||||
"left": 200,
|
||||
"attrs": { "color": "yellow", "key": "4", "label": "4" }
|
||||
},
|
||||
{
|
||||
"type": "wokwi-74hc595",
|
||||
"id": "sr1",
|
||||
"top": 171.8,
|
||||
"left": 361.16,
|
||||
"rotate": 180,
|
||||
"attrs": {}
|
||||
},
|
||||
{
|
||||
"type": "wokwi-74hc595",
|
||||
"id": "sr2",
|
||||
"top": 171.8,
|
||||
"left": 457.16,
|
||||
"rotate": 180,
|
||||
"attrs": {}
|
||||
},
|
||||
{ "type": "wokwi-7segment", "id": "sevseg1", "top": 47.16, "left": 379.48, "attrs": {} },
|
||||
{ "type": "wokwi-7segment", "id": "sevseg2", "top": 47.16, "left": 446.68, "attrs": {} }
|
||||
"type": "wokwi-resistor",
|
||||
"id": "r1",
|
||||
"top": 72,
|
||||
"left": 258.65,
|
||||
"rotate": 90,
|
||||
"attrs": { "value": "250" }
|
||||
}
|
||||
],
|
||||
"connections": [
|
||||
[ "uno:GND.1", "buzzer:1", "black", [ "v-12", "*", "h0" ] ],
|
||||
[ "uno:2", "btn-yellow:1.l", "gold", [ "v-48", "*", "h-6" ] ],
|
||||
[ "uno:GND.1", "btn-yellow:2.r", "black", [ "v-12", "*", "h6" ] ],
|
||||
[ "uno:3", "btn-blue:1.l", "blue", [ "v-44", "*", "h-10" ] ],
|
||||
[ "uno:GND.1", "btn-blue:2.r", "black", [ "v-12", "*", "h6" ] ],
|
||||
[ "uno:4", "btn-green:2.r", "green", [ "v-40", "*", "h6" ] ],
|
||||
[ "uno:GND.1", "btn-green:1.l", "black", [ "v-12", "*", "h-6" ] ],
|
||||
[ "uno:5", "btn-red:2.r", "orange", [ "v-36", "*", "h10" ] ],
|
||||
[ "uno:GND.1", "btn-red:1.l", "black", [ "v-12", "*", "h-6" ] ],
|
||||
[ "uno:8", "buzzer:2", "purple", [ "v-32", "*", "h0" ] ],
|
||||
[ "uno:9", "led-yellow:A", "gold", [ "v-28", "*", "h0" ] ],
|
||||
[ "uno:GND.1", "led-yellow:C", "black", [ "v-12", "*", "h-15", "v4" ] ],
|
||||
[ "uno:10", "led-blue:A", "blue", [ "v-24", "*", "h8" ] ],
|
||||
[ "uno:GND.1", "led-blue:C", "black", [ "v-12", "*", "h-15", "v4" ] ],
|
||||
[ "uno:11", "led-green:A", "green", [ "v-20", "*", "h0" ] ],
|
||||
[ "uno:GND.1", "led-green:C", "black", [ "v-12", "*", "h-8", "v4" ] ],
|
||||
[ "uno:12", "led-red:A", "orange", [ "v-16", "*", "h6" ] ],
|
||||
[ "uno:GND.1", "led-red:C", "black", [ "v-12", "*", "h-8", "v4" ] ],
|
||||
[ "uno:5V", "sr1:VCC", "red", [ "v57.5", "h253.4" ] ],
|
||||
[ "uno:A2", "sr1:SHCP", "gray", [ "v19.1", "h138.4" ] ],
|
||||
[ "uno:A1", "sr1:STCP", "purple", [ "v28.7", "h157.5" ] ],
|
||||
[ "uno:A0", "sr1:DS", "blue", [ "v38.3", "h186.2" ] ],
|
||||
[ "sr1:SHCP", "sr2:SHCP", "gray", [ "v47", "h106.12" ] ],
|
||||
[ "sr1:STCP", "sr2:STCP", "purple", [ "v37.4", "h96.52" ] ],
|
||||
[ "sr1:Q7S", "sr2:DS", "blue", [ "h0.52", "v56.6", "h144" ] ],
|
||||
[ "sr1:VCC", "sr1:MR", "red", [ "v17", "h-57.6" ] ],
|
||||
[ "sr1:VCC", "sr2:MR", "red", [ "v17", "h38.4" ] ],
|
||||
[ "sr1:VCC", "sr2:VCC", "red", [ "v17", "h96" ] ],
|
||||
[ "sr1:OE", "sr2:OE", "black", [ "v26.6", "h96" ] ],
|
||||
[ "sr1:MR", "sevseg1:COM.1", "red", [ "v17", "h-57.6", "v-96", "h76.8" ] ],
|
||||
[ "sevseg1:COM.1", "sevseg2:COM.1", "red", [ "h0", "v9.6", "h57.6" ] ],
|
||||
[ "sr2:Q0", "sevseg2:A", "green", [ "v7.4", "h28.8", "v-182.4", "h-67.2" ] ],
|
||||
[ "sr2:Q1", "sevseg2:B", "green", [ "v0", "h9.6", "v-134.4", "h-48" ] ],
|
||||
[ "sr2:Q2", "sevseg2:C", "green", [ "v-38.4", "h-38.4" ] ],
|
||||
[ "sr2:Q3", "sevseg2:D", "green", [ "v-33.6", "h-33.6", "v-9.6", "h-14.4" ] ],
|
||||
[ "sr2:Q4", "sevseg2:E", "green", [ "v-28.8", "h-28.8", "v-9.6", "h-14.4" ] ],
|
||||
[ "sr2:Q5", "sevseg2:F", "green", [ "v-24", "h-24", "v-9.6", "h-24", "v-110.4", "h19.2" ] ],
|
||||
[ "sr2:Q6", "sevseg2:G", "green", [ "v-19.2", "h-43.2", "v-115.2", "h14.4" ] ],
|
||||
[ "sr1:GND", "sr2:GND", "black", [ "v-9.6", "h96" ] ],
|
||||
[ "sr1:Q1", "sevseg1:B", "green", [ "v-134.4", "h-19.2" ] ],
|
||||
[ "sr1:Q2", "sevseg1:C", "green", [ "v-38.4", "h-19.2" ] ],
|
||||
[ "sr1:Q3", "sevseg1:D", "green", [ "v-33.6", "h-24" ] ],
|
||||
[ "sr1:Q4", "sevseg1:E", "green", [ "v-28.8", "h-28.8" ] ],
|
||||
[ "uno:GND.3", "sr1:GND", "black", [ "v47.9", "h157.6", "v-259.2", "h9.6" ] ],
|
||||
[ "sr1:GND", "sr1:OE", "black", [ "v-9.6", "h-9.6", "v67.2", "h172.8" ] ],
|
||||
[ "sr1:Q0", "sevseg1:A", "green", [ "v65", "h-76.8", "v-240", "h57.6" ] ],
|
||||
[ "sr1:Q5", "sevseg1:F", "green", [ "v-24", "h-19.2", "v-110.4", "h19.2" ] ],
|
||||
[ "sr1:Q6", "sevseg1:G", "green", [ "v-19.2", "h-14.4", "v-110.4", "h14.4" ] ]
|
||||
]
|
||||
[ "uno:GND.1", "bb1:tn.1", "black", [ "v0" ] ],
|
||||
[ "bb1:tn.2", "bb1:5t.a", "green", [ "v0" ] ],
|
||||
[ "bb1:5t.e", "bb1:5b.f", "green", [ "v0" ] ],
|
||||
[ "uno:13", "bb1:6t.a", "green", [ "v0" ] ],
|
||||
[ "r1:1", "bb1:6t.b", "", [ "$bb" ] ],
|
||||
[ "r1:2", "bb1:6b.f", "", [ "$bb" ] ],
|
||||
[ "led1:A", "bb1:6b.j", "", [ "$bb" ] ],
|
||||
[ "led1:C", "bb1:5b.j", "", [ "$bb" ] ]
|
||||
],
|
||||
"dependencies": {}
|
||||
}
|
@ -1,94 +0,0 @@
|
||||
/**************************************************
|
||||
This file defines constants with the frequency
|
||||
of different musical notes.
|
||||
*************************************************/
|
||||
|
||||
#define NOTE_B0 31
|
||||
#define NOTE_C1 33
|
||||
#define NOTE_CS1 35
|
||||
#define NOTE_D1 37
|
||||
#define NOTE_DS1 39
|
||||
#define NOTE_E1 41
|
||||
#define NOTE_F1 44
|
||||
#define NOTE_FS1 46
|
||||
#define NOTE_G1 49
|
||||
#define NOTE_GS1 52
|
||||
#define NOTE_A1 55
|
||||
#define NOTE_AS1 58
|
||||
#define NOTE_B1 62
|
||||
#define NOTE_C2 65
|
||||
#define NOTE_CS2 69
|
||||
#define NOTE_D2 73
|
||||
#define NOTE_DS2 78
|
||||
#define NOTE_E2 82
|
||||
#define NOTE_F2 87
|
||||
#define NOTE_FS2 93
|
||||
#define NOTE_G2 98
|
||||
#define NOTE_GS2 104
|
||||
#define NOTE_A2 110
|
||||
#define NOTE_AS2 117
|
||||
#define NOTE_B2 123
|
||||
#define NOTE_C3 131
|
||||
#define NOTE_CS3 139
|
||||
#define NOTE_D3 147
|
||||
#define NOTE_DS3 156
|
||||
#define NOTE_E3 165
|
||||
#define NOTE_F3 175
|
||||
#define NOTE_FS3 185
|
||||
#define NOTE_G3 196
|
||||
#define NOTE_GS3 208
|
||||
#define NOTE_A3 220
|
||||
#define NOTE_AS3 233
|
||||
#define NOTE_B3 247
|
||||
#define NOTE_C4 262
|
||||
#define NOTE_CS4 277
|
||||
#define NOTE_D4 294
|
||||
#define NOTE_DS4 311
|
||||
#define NOTE_E4 330
|
||||
#define NOTE_F4 349
|
||||
#define NOTE_FS4 370
|
||||
#define NOTE_G4 392
|
||||
#define NOTE_GS4 415
|
||||
#define NOTE_A4 440
|
||||
#define NOTE_AS4 466
|
||||
#define NOTE_B4 494
|
||||
#define NOTE_C5 523
|
||||
#define NOTE_CS5 554
|
||||
#define NOTE_D5 587
|
||||
#define NOTE_DS5 622
|
||||
#define NOTE_E5 659
|
||||
#define NOTE_F5 698
|
||||
#define NOTE_FS5 740
|
||||
#define NOTE_G5 784
|
||||
#define NOTE_GS5 831
|
||||
#define NOTE_A5 880
|
||||
#define NOTE_AS5 932
|
||||
#define NOTE_B5 988
|
||||
#define NOTE_C6 1047
|
||||
#define NOTE_CS6 1109
|
||||
#define NOTE_D6 1175
|
||||
#define NOTE_DS6 1245
|
||||
#define NOTE_E6 1319
|
||||
#define NOTE_F6 1397
|
||||
#define NOTE_FS6 1480
|
||||
#define NOTE_G6 1568
|
||||
#define NOTE_GS6 1661
|
||||
#define NOTE_A6 1760
|
||||
#define NOTE_AS6 1865
|
||||
#define NOTE_B6 1976
|
||||
#define NOTE_C7 2093
|
||||
#define NOTE_CS7 2217
|
||||
#define NOTE_D7 2349
|
||||
#define NOTE_DS7 2489
|
||||
#define NOTE_E7 2637
|
||||
#define NOTE_F7 2794
|
||||
#define NOTE_FS7 2960
|
||||
#define NOTE_G7 3136
|
||||
#define NOTE_GS7 3322
|
||||
#define NOTE_A7 3520
|
||||
#define NOTE_AS7 3729
|
||||
#define NOTE_B7 3951
|
||||
#define NOTE_C8 4186
|
||||
#define NOTE_CS8 4435
|
||||
#define NOTE_D8 4699
|
||||
#define NOTE_DS8 4978
|
202
src/main.cpp
202
src/main.cpp
@ -1,203 +1,13 @@
|
||||
/**
|
||||
Simon Game for Arduino with Score display
|
||||
|
||||
Copyright (C) 2022, Uri Shaked
|
||||
|
||||
Released under the MIT License.
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <pitches.h>
|
||||
|
||||
/* Constants - define pin numbers for LEDs,
|
||||
buttons and speaker, and also the game tones: */
|
||||
const uint8_t ledPins[] = {9, 10, 11, 12};
|
||||
const uint8_t buttonPins[] = {2, 3, 4, 5};
|
||||
#define SPEAKER_PIN 8
|
||||
|
||||
// These are connected to 74HC595 shift register (used to show game score):
|
||||
const int LATCH_PIN = A1; // 74HC595 pin 12
|
||||
const int DATA_PIN = A0; // 74HC595pin 14
|
||||
const int CLOCK_PIN = A2; // 74HC595 pin 11
|
||||
|
||||
#define MAX_GAME_LENGTH 100
|
||||
|
||||
const int gameTones[] = { NOTE_G3, NOTE_C4, NOTE_E4, NOTE_G5};
|
||||
|
||||
/* Global variables - store the game state */
|
||||
uint8_t gameSequence[MAX_GAME_LENGTH] = {0};
|
||||
uint8_t gameIndex = 0;
|
||||
|
||||
/**
|
||||
Set up the Arduino board and initialize Serial communication
|
||||
*/
|
||||
int pin13 = 13;
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
for (byte i = 0; i < 4; i++) {
|
||||
pinMode(ledPins[i], OUTPUT);
|
||||
pinMode(buttonPins[i], INPUT_PULLUP);
|
||||
}
|
||||
pinMode(SPEAKER_PIN, OUTPUT);
|
||||
pinMode(LATCH_PIN, OUTPUT);
|
||||
pinMode(CLOCK_PIN, OUTPUT);
|
||||
pinMode(DATA_PIN, OUTPUT);
|
||||
|
||||
// The following line primes the random number generator.
|
||||
// It assumes pin A3 is floating (disconnected):
|
||||
randomSeed(analogRead(A3));
|
||||
pinMode(pin13, OUTPUT);
|
||||
}
|
||||
|
||||
/* Digit table for the 7-segment display */
|
||||
const uint8_t digitTable[] = {
|
||||
0b11000000,
|
||||
0b11111001,
|
||||
0b10100100,
|
||||
0b10110000,
|
||||
0b10011001,
|
||||
0b10010010,
|
||||
0b10000010,
|
||||
0b11111000,
|
||||
0b10000000,
|
||||
0b10010000,
|
||||
};
|
||||
const uint8_t DASH = 0b10111111;
|
||||
|
||||
void sendScore(uint8_t high, uint8_t low) {
|
||||
digitalWrite(LATCH_PIN, LOW);
|
||||
shiftOut(DATA_PIN, CLOCK_PIN, MSBFIRST, low);
|
||||
shiftOut(DATA_PIN, CLOCK_PIN, MSBFIRST, high);
|
||||
digitalWrite(LATCH_PIN, HIGH);
|
||||
}
|
||||
|
||||
void displayScore() {
|
||||
int high = gameIndex % 100 / 10;
|
||||
int low = gameIndex % 10;
|
||||
sendScore(high ? digitTable[high] : 0xff, digitTable[low]);
|
||||
}
|
||||
|
||||
/**
|
||||
Lights the given LED and plays a suitable tone
|
||||
*/
|
||||
void lightLedAndPlayTone(byte ledIndex) {
|
||||
digitalWrite(ledPins[ledIndex], HIGH);
|
||||
tone(SPEAKER_PIN, gameTones[ledIndex]);
|
||||
delay(300);
|
||||
digitalWrite(ledPins[ledIndex], LOW);
|
||||
noTone(SPEAKER_PIN);
|
||||
}
|
||||
|
||||
/**
|
||||
Plays the current sequence of notes that the user has to repeat
|
||||
*/
|
||||
void playSequence() {
|
||||
for (int i = 0; i < gameIndex; i++) {
|
||||
byte currentLed = gameSequence[i];
|
||||
lightLedAndPlayTone(currentLed);
|
||||
delay(50);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Waits until the user pressed one of the buttons,
|
||||
and returns the index of that button
|
||||
*/
|
||||
byte readButtons() {
|
||||
while (true) {
|
||||
for (byte i = 0; i < 4; i++) {
|
||||
byte buttonPin = buttonPins[i];
|
||||
if (digitalRead(buttonPin) == LOW) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
delay(1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Play the game over sequence, and report the game score
|
||||
*/
|
||||
void gameOver() {
|
||||
Serial.print("Game over! your score: ");
|
||||
Serial.println(gameIndex - 1);
|
||||
gameIndex = 0;
|
||||
delay(200);
|
||||
|
||||
// Play a Wah-Wah-Wah-Wah sound
|
||||
tone(SPEAKER_PIN, NOTE_DS5);
|
||||
delay(300);
|
||||
tone(SPEAKER_PIN, NOTE_D5);
|
||||
delay(300);
|
||||
tone(SPEAKER_PIN, NOTE_CS5);
|
||||
delay(300);
|
||||
for (byte i = 0; i < 10; i++) {
|
||||
for (int pitch = -10; pitch <= 10; pitch++) {
|
||||
tone(SPEAKER_PIN, NOTE_C5 + pitch);
|
||||
delay(5);
|
||||
}
|
||||
}
|
||||
noTone(SPEAKER_PIN);
|
||||
|
||||
sendScore(DASH, DASH);
|
||||
delay(500);
|
||||
}
|
||||
|
||||
/**
|
||||
Get the user's input and compare it with the expected sequence.
|
||||
*/
|
||||
bool checkUserSequence() {
|
||||
for (int i = 0; i < gameIndex; i++) {
|
||||
byte expectedButton = gameSequence[i];
|
||||
byte actualButton = readButtons();
|
||||
lightLedAndPlayTone(actualButton);
|
||||
if (expectedButton != actualButton) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
Plays a hooray sound whenever the user finishes a level
|
||||
*/
|
||||
void playLevelUpSound() {
|
||||
tone(SPEAKER_PIN, NOTE_E4);
|
||||
delay(150);
|
||||
tone(SPEAKER_PIN, NOTE_G4);
|
||||
delay(150);
|
||||
tone(SPEAKER_PIN, NOTE_E5);
|
||||
delay(150);
|
||||
tone(SPEAKER_PIN, NOTE_C5);
|
||||
delay(150);
|
||||
tone(SPEAKER_PIN, NOTE_D5);
|
||||
delay(150);
|
||||
tone(SPEAKER_PIN, NOTE_G5);
|
||||
delay(150);
|
||||
noTone(SPEAKER_PIN);
|
||||
}
|
||||
|
||||
/**
|
||||
The main game loop
|
||||
*/
|
||||
void loop() {
|
||||
displayScore();
|
||||
|
||||
// Add a random color to the end of the sequence
|
||||
gameSequence[gameIndex] = random(0, 4);
|
||||
gameIndex++;
|
||||
if (gameIndex >= MAX_GAME_LENGTH) {
|
||||
gameIndex = MAX_GAME_LENGTH - 1;
|
||||
}
|
||||
|
||||
playSequence();
|
||||
if (!checkUserSequence()) {
|
||||
gameOver();
|
||||
}
|
||||
|
||||
delay(300);
|
||||
|
||||
if (gameIndex > 0) {
|
||||
playLevelUpSound();
|
||||
delay(300);
|
||||
}
|
||||
delay(3000);
|
||||
digitalWrite(pin13, HIGH);
|
||||
delay(3000);
|
||||
digitalWrite(pin13, LOW);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user