Close

~monday 16th december~

A project log for PouleShootClapPool

A new different version of the well-know game, Dance Dance Revolution (DDR)

manglegounounMangèleGOUNOUN 12/16/2024 at 12:500 Comments

~monday 16th december~ ~Ovation~

Today is the day, we finally finish !!!

So the code of yesterday is working with the cymaballs, is not totally what we think it will sound but yeah it still does work and we are so happy.

here it is :

const int BUTTON_PIN = 7;   // Pin du bouton
const int BUZZER_PIN = 3;   // Pin du buzzer

void setup() {
  Serial.begin(9600);               // Initialisation de la communication série
  pinMode(BUTTON_PIN, INPUT_PULLUP); // Pin du bouton en mode entrée avec résistance interne
  pinMode(BUZZER_PIN, OUTPUT);      // Pin du buzzer en mode sortie
}

void loop() {
  int buttonState = digitalRead(BUTTON_PIN); // Lecture de l'état du bouton
  
  if (buttonState == LOW) { // Si le bouton est pressé (état LOW)
    Serial.println("Le bouton est pressé");
    playCymbals();  // Jouer le son des cymbales
  } else { // Si le bouton n'est pas pressé (état HIGH)
    Serial.println("Le bouton n'est pas pressé");
    noTone(BUZZER_PIN); // Arrêter le son du buzzer
  }
}

// Fonction pour simuler le son des cymbales
void playCymbals() {
  unsigned long totalDuration = 200; // Durée totale du son des cymbales en millisecondes
  unsigned long startTime = millis(); // Temps de début du son

  // Génération de fréquences aléatoires pour simuler le son des cymbales
  while (millis() - startTime < totalDuration) {
    int freq = random(3000, 8000);       // Fréquences aiguës entre 3 kHz et 8 kHz
    int noteDuration = random(10, 50);   // Durées courtes des notes entre 10 et 50 ms
    tone(BUZZER_PIN, freq, noteDuration); // Jouer la note
    delay(noteDuration); // Attente avant de jouer la prochaine note
  }

  noTone(BUZZER_PIN); // Arrêter le son une fois la durée écoulée
}

 Then we also finished the instructions, we hope it will help you if you want to do the same haha.

So here are some pictures of our project:

we are really thankfull on your investement in our project thankk yooouuuu <3 

Discussions