mcfeaters2001
Published © GPL3+

Wire Loop Game

simple, easy, fun, game to make in around 20 minutes. This has detailed code and notes and hopefuly it actually works.

BeginnerFull instructions provided1,580
Wire Loop Game

Things used in this project

Hardware components

3 mm LED: Red
3 mm LED: Red
×1
3 mm LED: Green
3 mm LED: Green
×1
Buzzer
Buzzer
optional
×1
Jumper wires (generic)
Jumper wires (generic)
×22
Arduino UNO
Arduino UNO
×1
Resistor 330 ohm
Resistor 330 ohm
×2
Resistor 1k ohm
Resistor 1k ohm
×1
Resistor 10k ohm
Resistor 10k ohm
×2
7 Segment LED Display, InfoVue
7 Segment LED Display, InfoVue
×1
Slide Switch
Slide Switch
optional
×2
Solderless Breadboard Full Size
Solderless Breadboard Full Size
×1

Story

Read more

Schematics

steady_game_oupxLFcYvw.fzz

steady_game_skematics_h7MAYQWF46.png

Code

Steady Game

Arduino
int pinA = 2;                    //this is used for displaying the numbers
int pinB = 3;
int pinC = 4;
int pinD = 5;
int pinE = 6;
int pinF = 7;
int pinG = 8;
int counterpin = 9;               //pullup resistor wire sensor
int redled = 10;
int buzzer = 11;
int winpin = 12;                  //pullup resistor win sensor
int greenled = 13;
int count;                        //declaring the variables
int buttonstate;
int dt = 300;                     //these are the delay variables
int cd = 300;
int ed = 400;
int wind = 300;
int counttone = 800;              //these are the buzzer tones
int endtone = 1500;
int wintone = 300;


void setup() {
  // put your setup code here, to run once:
 pinMode(pinA, OUTPUT);           //sets the initial number and count to 0
  pinMode(pinB, OUTPUT);     
  pinMode(pinC, OUTPUT);     
  pinMode(pinD, OUTPUT);     
  pinMode(pinE, OUTPUT);     
  pinMode(pinF, OUTPUT);     
  pinMode(pinG, OUTPUT); 
  pinMode (counterpin, INPUT);
  pinMode(redled,OUTPUT);
  pinMode (buzzer, OUTPUT);
  pinMode (winpin, INPUT);
  pinMode (greenled,OUTPUT);
  count = 0;
 Serial.begin(9600); 

}

void loop() {
  // put your main code here, to run repeatedly:
  buttonstate = digitalRead(counterpin);
  if (buttonstate == 0) {                         //when the pullup resistor sees a drop in voltage the wires are touching
    count ++;
    tone(buzzer, counttone);
  delay (cd);
noTone (buzzer);
  }
  
  Serial.print ( " the button state is ");        //this displays some of the variables inside the serial moitor
  Serial.print (buttonstate);
  Serial.print (" the count is ");
  Serial.println (count);

if (digitalRead(winpin) == 0){                    //sets the loop for winning the game
  
  digitalWrite (greenled,HIGH);
  tone(buzzer, wintone);
  delay (wind);
  noTone(buzzer);
  tone(buzzer, wintone);
  delay(wind);
  noTone(buzzer);
  delay (wind);
  tone(buzzer, wintone);
  delay(wind);
  noTone(buzzer);
  digitalWrite (greenled, LOW);
  count = 0;                            //resets the number and count to 0
   digitalWrite(pinA, LOW);   
  digitalWrite(pinB, LOW);   
  digitalWrite(pinC, LOW);   
  digitalWrite(pinD, LOW);   
  digitalWrite(pinE, LOW);   
  digitalWrite(pinF, LOW);   
  digitalWrite(pinG, LOW); 
}
  
  if (count ==1){                   //uses the variables to display numbers to the 7-digit display
    
  
  digitalWrite(pinA, LOW);   
  digitalWrite(pinB, HIGH);   
  digitalWrite(pinC, HIGH);   
  digitalWrite(pinD, LOW);   
  digitalWrite(pinE, LOW);   
  digitalWrite(pinF, LOW);   
  digitalWrite(pinG, LOW); 

  delay(dt);     
  }
  if (count ==2){
    digitalWrite(pinA, HIGH);   
  digitalWrite(pinB, HIGH);   
  digitalWrite(pinC, LOW);   
  digitalWrite(pinD, HIGH);   
  digitalWrite(pinE, HIGH);   
  digitalWrite(pinF, LOW);   
  digitalWrite(pinG, HIGH); 

  delay(dt);      
  }
  if (count == 3){
     digitalWrite(pinA, HIGH);   
  digitalWrite(pinB, HIGH);   
  digitalWrite(pinC, HIGH);   
  digitalWrite(pinD, HIGH);   
  digitalWrite(pinE, LOW);   
  digitalWrite(pinF, LOW);   
  digitalWrite(pinG, HIGH);
   
  delay (dt);
  }
  if (count == 4){
   digitalWrite(pinA, LOW);   
  digitalWrite(pinB, HIGH);   
  digitalWrite(pinC, HIGH);   
  digitalWrite(pinD, LOW);   
  digitalWrite(pinE, LOW);   
  digitalWrite(pinF, HIGH);   
  digitalWrite(pinG, HIGH);
  
  delay(dt); 
  }
  if (count == 5){
      digitalWrite(pinA, HIGH);   
  digitalWrite(pinB, LOW);   
  digitalWrite(pinC, HIGH);   
  digitalWrite(pinD, HIGH);   
  digitalWrite(pinE, LOW);   
  digitalWrite(pinF, HIGH);   
  digitalWrite(pinG, HIGH);  
  
  delay(dt); 
  }
  if (count == 6){
     digitalWrite(pinA, HIGH);   
  digitalWrite(pinB, LOW);   
  digitalWrite(pinC, HIGH);   
  digitalWrite(pinD, HIGH);   
  digitalWrite(pinE, HIGH);   
  digitalWrite(pinF, HIGH);   
  digitalWrite(pinG, HIGH);  
   
  delay(dt); 
  }
  if (count == 7 ){
    digitalWrite(pinA, HIGH);   
  digitalWrite(pinB, HIGH);   
  digitalWrite(pinC, HIGH);   
  digitalWrite(pinD, LOW);   
  digitalWrite(pinE, LOW);   
  digitalWrite(pinF, LOW);   
  digitalWrite(pinG, LOW);  
    
  delay(dt);
  }
  if (count == 8 ){
     digitalWrite(pinA, HIGH);   
  digitalWrite(pinB, HIGH);   
  digitalWrite(pinC, HIGH);   
  digitalWrite(pinD, HIGH);   
  digitalWrite(pinE, HIGH);   
  digitalWrite(pinF, HIGH);   
  digitalWrite(pinG, HIGH); 
     
  delay(dt);
  }
  if (count == 9){
    digitalWrite(pinA, HIGH);   
  digitalWrite(pinB, HIGH);   
  digitalWrite(pinC, HIGH);   
  digitalWrite(pinD, LOW);   
  digitalWrite(pinE, LOW);   
  digitalWrite(pinF, HIGH);   
  digitalWrite(pinG, HIGH); 
     
  delay(dt);

  }
  if(count == 10){                        //the loop for losing
    count = 0;
    digitalWrite (redled, HIGH);
    tone (buzzer, endtone);
    delay(ed);
    noTone (buzzer);
    tone (buzzer, endtone);
    delay(ed);
    noTone (buzzer);
    tone (buzzer, endtone);
    delay(ed);
    noTone (buzzer);
    
     digitalWrite(pinA, LOW);   
  digitalWrite(pinB, LOW);   
  digitalWrite(pinC, LOW);   
  digitalWrite(pinD, LOW);   
  digitalWrite(pinE, LOW);   
  digitalWrite(pinF, LOW);   
  digitalWrite(pinG, LOW);

  digitalWrite(redled,LOW);
 
  }
  delay (100);
}

Credits

mcfeaters2001

mcfeaters2001

0 projects • 0 followers

Comments