ENIB 2022 - groupe A : Memory Game : Différence entre versions

De Les Fabriques du Ponant
Aller à : navigation, rechercher
(Page créée avec « ==photo de l'équipe== 600px ==Que fait ce projet ? == Ce projet est un Simon avec 4 leds et 4 boutons poussoirs. ==Liste des composants==... »)
 
(Code)
Ligne 14 : Ligne 14 :
  
  
==Code==
+
// Simple SIMON Code
<pre>
+
// By James Cameron, 2020
ici je pose mon code documenté !
+
//
</pre>
+
// 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==
 
==Catégories==
  
 
[[Catégorie:Enib2022]]
 
[[Catégorie:Enib2022]]

Version du 13 janvier 2022 à 16:59

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