Hi, We Have build Buzz Wire Game using, is any one help me out?
#include <Arduino.h>
const int buzzerPin = 26; // Connect buzzer to GPIO 26
const int buttonPin = 34; // Connect button to GPIO 34
// Define the sequence of notes (adjust as needed)
const int notes[] = {262, 294, 329, 349, 392, 440, 494}; // C4, D4, E4, F4, G4, A4, B4
// Function to play a single note
void playNote(int note, int duration) {
tone(buzzerPin, note, duration);
delay(duration);
noTone(buzzerPin);
}
void setup() {
pinMode(buzzerPin, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP); // Use internal pull-up resistor
Serial.begin(115200);
}
void loop() {
// Wait for button press
while (digitalRead(buttonPin) == HIGH) {
delay(10);
}
// Play the sequence of notes
for (int i = 0; i < sizeof(notes) / sizeof(notes[0]); i++) {
playNote(notes[i], 500); // Play each note for 500ms
}
Serial.println("Game Over!");
}
Which Arduino board are you using ?
Please post your sketch, using code tags when you do
Posting your code using code tags prevents parts of it being interpreted as HTML coding and makes it easier to copy for examination
In my experience the easiest way to tidy up the code and add the code tags is as follows
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.
Hello Dave, we have building gaming arcade machines, i have attached 3 videos files, the flower are like bonus points, the flower petal will have metal aluminium tape and will be connect to ESP32, there is 5 flowers,
I see 5 still images and 0 videos, but that's fine. It looks like you have done a lot of work.
Is the problem you were having fixed now?
If not, please ask for more help, giving details (sketch and schematic) and explain what's not working (what you would like it to do + what it's actually doing). If it's aready fixed, what did you do to fix it?
i have not made any connections yet, here is the game play flow chart.
// CONSTANTS
// The "start zone" which players must touch to start the game each time
const byte startPin = 8;
// Touching any part of the wire itself causes a failure
const byte failPin = 9;
// The "win zone" at the end of the wire
const byte endPin = 10;
// A piezo buzzer chirps to signify success/failure
const byte buzzerPin = 6;
// GLOBALS
// Keep track of the current states of the game
enum GameState {FAILED, IN_PROGRESS, SUCCESS};
GameState gameState = GameState::FAILED;
void setup() {
// Set the pins to the correct mode
pinMode(startPin, INPUT_PULLUP);
pinMode(failPin, INPUT_PULLUP);
pinMode(endPin, INPUT_PULLUP);
pinMode(buzzerPin, OUTPUT);
// Begin a serial connection for debugging
Serial.begin(9600);
}
void loop() {
switch(gameState) {
case GameState::IN_PROGRESS:
if(!digitalRead(endPin)) {
gameState = GameState::SUCCESS;
Serial.println("Congratulations!");
tone(buzzerPin, 440, 50);
delay(60);
tone(buzzerPin, 587, 250);
}
else if(!digitalRead(failPin)) {
gameState = GameState::FAILED;
Serial.println("FAILED");
tone(buzzerPin, 440, 200);
delay(200);
tone(buzzerPin, 415, 200);
delay(200);
tone(buzzerPin, 392, 200);
delay(200);
tone(buzzerPin, 370, 400);
}
break;
case GameState::FAILED:
case GameState::SUCCESS:
if(!digitalRead(startPin)) {
gameState = GameState::IN_PROGRESS;
Serial.println("New Game Started");
tone(buzzerPin, 440, 100);
delay(120);
tone(buzzerPin, 554, 100);
delay(120);
tone(buzzerPin, 659, 200);
}
break;
}
}
Hi Dave , I need to add flowers and bonus sound Track when the flower is touched, LED Filament bub Flashes,
Here is the Gameplay:-
" Instruction Button" when this button is pressed an "HOW TO PLAY, " instruction audio is played. this is for the visual challenged person and new players.
At Static/ ideal Position, 50% brightness LEDs and WS2818 light random movements.
When the coin is inserted, LED Bub Flashes and the Value of the coin Displayed on LCD display 16x2 module. Games begins in "5 4 3 2 1", and "Blur" effect of FastLED Library, can be running on WS2818.
Game ON
If the game is successfully completed " Light flashes, Celebration Music soundtrack is played and all the light on full brightness, funky colour on WS2818. on LCD screen display "congratulations , try with other hand".
else, Red light ON and on LCD Screen " Try Again" should print.
I suggest you write some separate sketches before trying to write the whole code:
Get the WS2818 working on its own so you know how to do that, and discover what patterns look good.
Get the coin reader working on its own and print the info to the serial monitor.
Get the LCD working on its own with text that you want to display in the game.
When you have done all that, work out how to merge it into the code that you posted in post #6. That code looks okay, but I haven't totally studied it.
If you have any problems with these steps then post questions here.
Thank you for your guidance and suggestions on this buzzer wire game project. Unfortunately, I have decided to discontinue working on this project due to a combination of factors. As someone who is not professionally trained as a programmer or engineer, I encountered significant challenges in developing the game. Additionally, budget limitations further constrained my ability to proceed.
Given that I am no longer actively pursuing this, I wanted to inquire if either of you or perhaps someone else in the forum community might be interested in taking over the project and potentially developing it further.