Whack-a-Hole / F1 Reactions – Matt Kersey – Eric

  • CONCEPTION AND DESIGN:

The idea for our Whack-a-Hole project was based off of retro video game styles that I had researched. I saw whack a mole, and I thought that with lights, this would make for an interesting project. The previous research led to this because I thought that a whack a mole game would fit my definition of interaction activities. I made levers and buttons because I knew that was how people would interact with it. I also made a hammer with it to give it more of that whack a mole feeling. My user testing was a little rocky. There was a minor wiring issue, but I fixed it before I presented but after my partner’s recitation. The user testing process made me brush it up, and make the rules more evident, so I would make a board that was above it that had the rules written in it. I made adaptations on processing to also make it more apparent. For instance, I added some whack a mole screen on processing to make it more apparent what the game was based off of. The changes we made were extremely effective.

  • Fabrication and Production

Let me regale you a tale. When I first planned the project I thought this would be a rather simple process… boy was I wrong. The first thing I did was make a prototype of what it would look like out of cardboard. I realized how much better it would look if we did it out of wood, and that’s what proceeded to happen. We made the box out of wood, and then we decided to paint it red to give it more color. We thought of using pressure sensors at the beginning, but we changed it to levers using copper tape and soldered wires. We thought it would make it more durable and more effective; therefore, the next step was to make the levers. At this point, I have been working day and night to make this seem like a decent project. I completed the buttons, and I started working on the code. I almost had to do it by myself because around the time all of the LAs and teachers were with other people who probably needed more help than me. I worked on the wiring, and I kept running into one problem, the device kept on short circuiting. It was only sometimes though, so it was tolerable if I only needed to test it a couple times for user testing. After user testing, it became a bit more dodgy. I hooked everything up and realized it started to short circuit more and more. I thought it was because it was getting an overload of power, so I added additional power sources to compensate, and it was working… for the time being. I improved the code to make it more user friendly, and more visually stimulating by adding the beginning screen. As mentioned, I also added the board to make the rules more apparent to the person who was interacting with it more. We also made the hammer lighter, so people wouldn’t break the LEDs or buttons. Now that we actually did something that set us forward quite a bit, let’s talk about the wiring. I had to have rewired this thing at least like five times. This made all of the short circuiting problems go from a level 1 issue to a level 10 issue. This would become a code red situation. I tried everything. I got everyone and everybody who was somewhat competent in wiring to look at it. I dismantled the wiring to try and find the issue, but the wiring was right. I legitimately could not find an issue. I even had one of my friends test the project, and it was working perfectly, but right after, it did not work at all. After this point, everything went down hill from here. After rewiring for the final time I proceeded to try and play it. Then, the arduino fried, and it became unusable. We would get another arduino after this, and it became a little bit worse. I rewired it again, and I had a new arduino. The arduino started smoking, and my project at this point started to look like a chimney that was emitting light smoke from the holes of it. I took the top off, and I had no idea what to do. I literally took the box, unplugged everything, and dumped the arduino in the trash. It was quite a stressful few minutes. After this, I contemplated my options. I came to the conclusion that I had too little time to figure out what was making my project short circuit. I had to turn something in though. The first I thought of was speed because of how little time I had. I thought of F1. I still thought of using the same wiring from my original project, and I thought I could use the same wiring for a reaction game. This is exactly what I did with the little time I had left. I had the wiring, I had a friend help make the car figure, and then I adjusted the code. I lived in the IMA lab basically for two weeks. My partner painted, and he overlooked and did some construction. Coding, wiring, design, everything else was practically mine.

 

  • Conclusion

The original goal of this project was to make an interactive game for people to enjoy. That quickly turned into just being able to make it work. My project (the one I presented) for what it was it completed the goal I had later down the line. The audience had mixed reception, but to be fair, we had pulled through with a project, and I was happy because of that. My project aligned with my thoughts of interaction perfectly. They both required human interaction to work and function. If I had more time, I would like to figure out what was blowing up the arduino on the first project. I learned so much from the setbacks and failures. That’s exactly what I took away from the entire project as a whole. The idea of everything failing, and having to think on my feet to get something in taught me something. Hopefully, I won’t ever have to do it again, but it did teach me the idea of failure and how to carry on after that.

 

  • Appendix 

Code for Arduino

 #include “SerialRecord.h”

SerialRecord writer(6);

SerialRecord reader(7);

int val2;

int val3;

int val4;

int val5;

int val6;

int val7;

// Pin definitions

const int ledPins[] = { 8, 9, 10, 11, 12, 13 };  // Pins for the LED lights

const int switchPins[] = { 2, 3, 4, 5, 6, 7 };   // Pins for the switches

// Game variables

const int numMoles = 6;

int activeMole = –1;  // Current active mole

int score = 0;

void setup() {

 // Initialize LED pins as OUTPUT

 for (int i = 0; i < numMoles; i++) {

   pinMode(ledPins[i], OUTPUT);

 }

 // Initialize switch pins as INPUT_PULLUP

 for (int i = 0; i < numMoles; i++) {

   pinMode(switchPins[i], INPUT_PULLUP);

 }

 randomSeed(analogRead(0));  // Seed the random number generator

 val2 = digitalRead(2);

 val3 = digitalRead(3);

 val4 = digitalRead(4);

 val5 = digitalRead(5);

 val6 = digitalRead(6);

 val7 = digitalRead(7);

 Serial.print(val2);

 Serial.print(“,”);

 Serial.print(val3);

 Serial.print(“,”);

 Serial.print(val4);

 Serial.print(“,”);

 Serial.print(val5);

 Serial.print(“,”);

 Serial.print(val6);

 Serial.print(“,”);

 Serial.print(val7);

 Serial.println();

 writer[0] = val2;

 writer[1] = val3;

 writer[2] = val4;

 writer[3] = val5;

 writer[4] = val6;

 writer[5] = val7;

}

void loop() {

 // Activate a random mole

 if (activeMole == –1) {

   activeMole = random(numMoles);

   digitalWrite(ledPins[activeMole], HIGH);

 }

 // Check for button presses

 for (int i = 0; i < numMoles; i++) {

   if (digitalRead(switchPins[i]) == LOW) {

     if (i == activeMole) {

       // Successful hit

       score++;

       digitalWrite(ledPins[i], LOW);

       delay(10);  // Delay to show hit feedback

     } else {

       // Wrong hit

       score–;

     }

     activeMole = –1;  // Reset active mole

     break;

   }

 }

 // Update the score

 Serial.println(“Score: “ + String(score));

 // Game over condition

 if (score >= 10) {

   // Game over

   resetGame();

 }

 delay(10);  // Delay between loops

}

void resetGame() {

 // Reset game variables

 score = 0;

 activeMole = –1;

 // Turn off all LEDs

 for (int i = 0; i < numMoles; i++) {

   digitalWrite(ledPins[i], LOW);

 }

 // Wait for a brief moment before starting a new iteration

 delay(1000);

}

Code for Processing

import processing.serial.*;

Serial arduino;
int timerStart = 0;
boolean gameStarted = false;

void setup() {
size(600, 400);
textAlign(CENTER, CENTER);
textSize(32);

// Replace ‘COM3’ with the appropriate port name for your Arduino
arduino = new Serial(this, “COM3”, 9600);
arduino.clear();
}

void draw() {
background(0);

if (gameStarted) {
// Check if the timer has started
if (timerStart > 0) {
// Calculate the elapsed time
int elapsedTime = millis() – timerStart;

// Display the elapsed time on the screen
fill(255); // Set text color to white
text(“Time: ” + elapsedTime / 1000 + ” s”, width / 2, height / 2);
} else {
// Display game in progress message
fill(255); // Set text color to white
text(“Game in Progress”, width / 2, height / 2);
}
} else {
// Display start menu
fill(255); // Set text color to white
text(“Whack-a-Mole”, width / 2, height / 2);
text(“Press ENTER to start”, width / 2, height / 2 + 40);
}
}

void keyPressed() {
if (keyCode == ENTER) {
gameStarted = true;
resetGame();
}
}

void serialEvent(Serial arduino) {
String data = arduino.readStringUntil(‘\n’);
if (data != null) {
data = trim(data);
int sensorValue = int(data);

if (sensorValue > 800) {
// Stop the timer
timerStart = 0;
} else if (gameStarted && timerStart == 0) {
// Start the timer when the LED turns on
timerStart = millis();
}
}
}

void resetGame() {
timerStart = 0;
arduino.write(‘r’); // Send ‘r’ character to Arduino to reset the game
}

Video #2

IMG_3202

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *