ENIB 2022 - groupe A : Memory Game

De Les Fabriques du Ponant
Révision datée du 13 janvier 2022 à 16:59 par Titouan (discussion | contributions) (Code)
Aller à : navigation, rechercher

photo de l'équipe

Photoenib2018.jpg

Que fait ce projet ?

Ce projet est un Simon avec 4 leds et 4 boutons poussoirs.

Liste des composants

  • 4 leds de différentes couleurs
  • 4 boutons poussoirs
  • 1 carte arduino uno
  • 1 carte labdec
  • 1 haut parleur piezo
  • des câbles


// Simple SIMON Code // By James Cameron, 2020 // // For Arduino UNO // // Pin Definitions : // Pin 2 - LED 1 (-) // Pin 3 - LED 2 (-) // Pin 4 - LED 3 (-) // Pin 5 - LED 4 (-) // Pin 6 - Button 1 (+) // Pin 7 - Button 2 (+) // Pin 8 - Button 3 (+) // Pin 9 - Button 4 (+) // Pin 11 - Speaker (+)

const int speaker = D1; // Set to the pin you connected the speaker to

//*****************************************

int LENGTH = 400; // Length of time to play the main notes

int notes[4] = {100, 350, 600, 850}; // Values for the 4 notes used in the game

int gamepattern[20]; // Array to store game pattern in during play

int difficulty = 1;

//*****************************************


void setup() {

 pinMode(D2, OUTPUT); // Set up LED PINS
 pinMode(D3, OUTPUT);
 pinMode(D4, OUTPUT);
 pinMode(D1, OUTPUT);
 pinMode(D6, INPUT); // Set up button pins
 pinMode(D7, INPUT);
 pinMode(D5, INPUT);
 pinMode(D0, INPUT);
 
 Serial.begin(9600); // Enable serial output so we can debug using the serial reader in the Arduino IDE

 }
 

void loop(){ digitalRead(D6); digitalRead(D7);

if (digitalRead(D6) == LOW)

   {
     digitalWrite (D2,HIGH);
   }
   else{      
     digitalWrite (D2,LOW);
     }
     

if (digitalRead(D7) == LOW)

   {
     digitalWrite (D3,HIGH);
   }
   else{      
     digitalWrite (D3,LOW);
     }

if (digitalRead(D5) == LOW)

   {
     digitalWrite (D4,HIGH);
   }
   else{      
     digitalWrite (D4,LOW);
     }
     if (digitalRead(D0) == LOW)
   {
     digitalWrite (D1,HIGH);
   }
   else{      
     digitalWrite (D1,LOW);
     }

}

Catégories