Introduction: Reaction Game

Picture of Reaction Game

This game was something I have seen before but on a much larger scale. This project is my HELLO WORLD into this. I used an Arudino UNO, 6 buttons, 6 leds, and two cutting boards to make this. This game is to help with arm eye coordination. This was something fun I do to get my feet wet in the game.

Step 1: Cutting the Cutting Boards

Picture of Cutting the Cutting Boards

I took one wood cutting boards and made legs for the other cutting board. This also allowed me to have a nice little handle to carry it around.

Step 2: Wiring

Picture of Wiring

Just a small hint:

MAKE SURE TO GROUND YOUR BUTTONS. THIS WILL CAUSE YOU LOTS OF TROUBLES.

Step 3: Wiring Part 2

Picture of Wiring Part 2

After making the game and testing in on a bread board. You will have to solder the wires to the buttons and then run all the wires back to the bread board which you will put on the button of your game board.

Step 4: Game Board

After soldering everything together and re-testing to make sure your soldering was good you will have to drill hole in the game board to run wires though. After running wires through it was helpful to hot glue it to the game board to make sure it stays.

Step 5: Testing

This is when I tested the game on some friends and this gave me some great feed back about how I could make the game better.

Step 6: Code

#include

int buttonpin1 = 2; int buttonpin2 = 3; int buttonpin3 = 4; int buttonpin4 = 5; int buttonpin5 = 6; int buttonpin6 = 7; int randomNumber = 0;

Bounce debouncerA = Bounce(); Bounce debouncerB = Bounce(); Bounce debouncerC = Bounce(); Bounce debouncerD = Bounce(); Bounce debouncerE = Bounce(); Bounce debouncerF = Bounce();

int buttonState1 = 0; int buttonState2 = 0; int buttonState3 = 0; int buttonState4 = 0; int buttonState5 = 0; int buttonState6 = 0;

const int ledPin1 = 13; const int ledPin2 = 12; const int ledPin3 = 11; const int ledPin4 = 10; const int ledPin5 = 9; const int ledPin6 = 8; int lastNumber; int pushNumber = 0;

enum State { DISPLAYLIGHT, WIN, LOSER };

State currentState;

byte digits[] = { B00100000, B00010000, B00001000, B00000100, B00000010, B00000001, B00111111, B00000000

};

int seg[] = { 13, 12, 11, 10, 9, 8 };

long currentTime = millis(); long LoseTime = 2000; long Timer=0;

void setup() { randomSeed(analogRead(A0)); Serial.begin(9600); pinMode(buttonpin1, INPUT); pinMode(buttonpin2, INPUT); pinMode(buttonpin3, INPUT); pinMode(buttonpin4, INPUT); pinMode(buttonpin5, INPUT); pinMode(buttonpin6, INPUT);

pinMode(ledPin1, OUTPUT); pinMode(ledPin2, OUTPUT); pinMode(ledPin3, OUTPUT); pinMode(ledPin4, OUTPUT); pinMode(ledPin5, OUTPUT); pinMode(ledPin6, OUTPUT);

debouncerA.attach(buttonpin1); debouncerB.attach(buttonpin2); debouncerC.attach(buttonpin3); debouncerD.attach(buttonpin4); debouncerE.attach(buttonpin5); debouncerF.attach(buttonpin6);

currentState = WIN;

}

void loop() { Serial.println(currentState); if (currentState == DISPLAYLIGHT) { for (int i = 0; i < 6; i++) { digitalWrite(seg[i], bitRead(digits[randomNumber], i)); }

} else if (currentState == WIN) { for (int i = 0; i < 6; i++) { digitalWrite(seg[i], bitRead(digits[6], i)); }

} else if (currentState == LOSER) { for (int i = 0; i < 6; i++) { digitalWrite(seg[i], bitRead(digits[7], i)); }

}

debouncerA.update(); debouncerB.update(); debouncerC.update(); debouncerD.update(); debouncerE.update(); debouncerF.update(); int pressedA = debouncerA.rose(); int pressedB = debouncerB.rose(); int pressedC = debouncerC.rose(); int pressedD = debouncerD.rose(); int pressedE = debouncerE.rose(); int pressedF = debouncerF.rose();

Serial.println(pressedA); //Serial.println(currentTime); //Serial.println(Timer); //delay(100); currentTime = millis();

if (currentState == DISPLAYLIGHT) { if(currentTime - Timer > LoseTime){ currentState = LOSER; }else if(pressedA && randomNumber ==5){ helperFunction(); }else if(pressedB && randomNumber ==4){ helperFunction(); }else if(pressedC && randomNumber ==3){ helperFunction(); }else if(pressedD && randomNumber ==2){ helperFunction(); }else if(pressedE && randomNumber ==1){ helperFunction(); }else if(pressedF && randomNumber ==0){ helperFunction(); }

} else if (currentState == WIN) { if (pressedA) { currentState = DISPLAYLIGHT; randomNumber = random(0,6); Timer = millis(); LoseTime = 2000; }

} else if (currentState == LOSER) { if (pressedA) { currentState = DISPLAYLIGHT; randomNumber = random(0,6); Timer = millis(); LoseTime = 2000; }

}

}

void helperFunction(){ lastNumber = randomNumber; currentState = DISPLAYLIGHT; randomNumber = random(0,6); if(lastNumber = randomNumber){ randomNumber = random(0,6); } Timer = millis(); LoseTime = LoseTime * .9; }

Comments

Swansong (author)2017-02-24

Looks like fun :)

About This Instructable

165views

3favorites

License:

More by spencer33russell:Light the World PhotographyCamp Fire GrillDrinks Low?
Add instructable to: