Midterm Interaction Lab

Plants VS Zombies – Lane Berat

 

  1. Context

 

The goal of our midterm project was to create something that demonstrated great interaction between humans and computers while also being extremely fun and engaging. This project is a zombie shooting game based off an app, where plants are used to shoot zombies. This interpretation of the game, with the two zombies as targets, where the player had to shoot down with a laser plant before it could reach the other side. When the target is hit, the target stops and the player loses. When the players shoot with a laser, our device receives and responds to it, triggering my understanding and definition of interaction.

 

General functionality:

 

To make our ideas a reality, on each of the targets, we used (LDR) and a servo motor to make the zombie move side to side. At first, we were thinking of using a servo motor connecting it to a piece of cardboard to make the zombie move. We then realized it wasn’t very efficient so we made cardboard conveyor belts that worked better with our project. We then added two joysticks to control both motors so that one player could control the zombies by moving left or right. We put light sensors in the zombie’s head and a light detector that would light up red if light was detected so we would know if the light was hitting the zombie. Using arcade buttons connected to super bright LED lights so a player could control the lights. 

 

Our users interacted with the project by pressing the buttons connected to the LED lights that would have a few-second interval before they could press the button again to make it harder for the user to win so easily. The other user would use two joysticks to control the zombies on the red and left of the board trying to avoid the LED light. Once the light sensor was activated and the sensor would go to red the user would lose. 

 

  1. Making the servo motor conveyor belt for the zombies  

(Zombie Research Facility) Pistol

 

We made the conveyor belt out of construction paper at first and figured out that it didn’t work well because it would not move. We then figured out how to use cardboard to build it making two sticks that have cardboard around them and the conveyor belt was also made from cardboard which worked much better. 

 

The Background

 

We used a big cardboard box with turf to make our project look like the game we were trying to recreate. We built two boxes on each side which would have the two different Arduino in them with all the wires. We also made different characters from the game out of cardboard that would be as decoration. We placed the zombies at one side and the plants at another. 

 

  1. Preparing The Targets

 

As targets, we used images of three different Zombies. We obtained images from a Google search and then printed them on paper. The images were then cut out and glued to cardboard. Because zombies can only be killed by being shot in the head, each target had a light sensor and a hole in their heads that allowed a sensor to be inserted. Servos were also glued to the sides of the conveyor belts. 

 

 Arduino Code

 

This was the trickiest part of our project. We had to face many setbacks and failures in this part but in the end, although it took us way more time than we had anticipated, we were able to do it in the end. This is the code we used for the super bright LED’s and the Arcade buttons. . 

 

int ledPin = 8;

int led2Pin = 9;

 

int yellowPin = 2;

int bluePin = 3;

 

int buttonVal;

int buttonVal2;

int pushButton;

int prevButtonState = 0;

unsigned long currentTime = 0;

unsigned long prevTime = 0;

unsigned long delayTime = 500;

unsigned long delayTime2 = 2000;

bool lightUp = true;

 

void setup() {

  pinMode(ledPin, OUTPUT);

  pinMode (led2Pin, OUTPUT);

  pinMode(yellowPin, INPUT);

  pinMode (bluePin, INPUT);

 

}

 

void loop() {

  buttonVal = digitalRead(yellowPin);

  buttonVal2 = digitalRead(bluePin);

  

 

  if (buttonVal == HIGH && pushButton == LOW && lightUp == true) {

    // Turn on LED

    digitalWrite(ledPin, HIGH);

    lightUp = false;

    

    prevTime = millis();

  } else {

    // if 3 seconds have passed since last button press

    

    if (millis() – prevTime >= delayTime) {

      // Turn off LED

      digitalWrite (ledPin, LOW);

 

      if (millis() – prevTime >= delayTime2){

        lightUp = true;

      }

    }

  }

  if (buttonVal2 == HIGH && pushButton == LOW && lightUp == true) {

    // Turn on LED

    digitalWrite (led2Pin, HIGH);

    lightUp = false;

    

    prevTime = millis();

  } else {

    // if 3 seconds have passed since last button press

    

    if (millis() – prevTime >= delayTime) {

      // Turn off LED

      digitalWrite (led2Pin, LOW);

 

      if (millis() – prevTime >= delayTime2){

        lightUp = true;

      }

    }

  }

 

  pushButton = buttonVal;

  Code for motor 

#define A_PIN  A0 

#define B_PIN  A1 

 

#define C_PIN  A2 

#define D_PIN  A3 

 

#define E_PIN  A5 

#define F_PIN  A6

 

#define UP_THRESHOLD    400

#define DOWN_THRESHOLD  800

#define COMMAND_NO   

#define COMMAND_VAL  

#define COMMAND_UP     

#define COMMAND_DOWN   

 

#include <AccelStepper.h>

 

int DIR_PIN = 2; 

int STEP_PIN = 3;

int EN_PIN = 4;

AccelStepper stepper(AccelStepper::DRIVER, STEP_PIN, DIR_PIN);

 

int MOTOR1_PIN = 5;

int MOTOR2_PIN = 6;

int MOTOR3_PIN = 7;

 

int MOTOR4_PIN = 8;

int MOTOR5_PIN = 9;

int MOTOR6_PIN = 10;

 

int xValue = 0 ; 

int yValue = 0 ; 

int cValue = 0 ; 

int dValue = 0 ; 

int eValue = 0 ; 

int fValue = 0 ; 

int command = COMMAND_NO;

int command2 = COMMAND_VAL;

 

void setup() {

  //joystick

  Serial.begin(9600) ;

 

  // Enable the stepper driver by setting the

  // EN pin to LOW

  pinMode(EN_PIN, OUTPUT);

  digitalWrite(EN_PIN, LOW);

  // The run() function will accelerate up to

  // the speed set here

  stepper.setMaxSpeed(1000);

  // Set the desired constant speed for use with

  // runSpeed()

  stepper.setSpeed(500); 

}

 

void loop() {

  xValue = analogRead(A_PIN);

  yValue = analogRead(B_PIN);

 

  cValue = analogRead(C_PIN);

  dValue = analogRead(D_PIN);

 

 

  eValue = analogRead(E_PIN);

  fValue = analogRead(F_PIN); 

 

  // converts the analog value to commands

  // reset commands

  command = COMMAND_NO;

 

 

  // check up/down commands

  if (yValue < UP_THRESHOLD)

    command = command | COMMAND_UP;

  else if (yValue > DOWN_THRESHOLD)

    command = command | COMMAND_DOWN;

 

 

  if (command & COMMAND_UP &&  stepper.runSpeed()) {

    Serial.println(“COMMAND 3”);

    // move accelstepper clockwise

  }

 

  if (command & COMMAND_DOWN && stepper.runSpeed()) {

    Serial.println(“COMMAND DOWN”);

    // move accelstepper counterclockwise 

 

   

   //for joystick 2

    // converts the analog value to commands

  // reset commands

  command2 = COMMAND_VAL;

 

 

  // check up/down commands

  if (cValue < UP_THRESHOLD)

    command2 = command2 | COMMAND_UP;

  else if (dValue > DOWN_THRESHOLD)

    command2 = command2 | COMMAND_DOWN;

 

 

  if (command2 & COMMAND_UP &&  stepper.runSpeed()) {

    Serial.println(“COMMAND UP”);

    // move accelstepper clockwise

  }

 

  if (command2 & COMMAND_DOWN && stepper.runSpeed()) {

    Serial.println(“COMMAND DOWN”);

    // move accelstepper counterclockwise 

  }

}

 

}

}

 

CONCLUSIONS:

 

To recap, the purpose of project was entertaining our users by making them play a physical plants vs zombie game. I believe the outcome of our project aligned with my concept of interaction, the project’s goal was to amuse our users by making them play a zombie-shooting game. During the testing, even when we only had one working, it was still fun for users to play, so I believe the outcome of our project aligned with my concept of interaction.

 

I believe it is important to mention. This project, I believe, was a great learning experience for us. It was a roller coaster ride with many setbacks and successes. I believe my partner and I could’ve worked better on the communication throughout our building process for our project. We spent days working on building items we did not end up using which was why we had to rush to complete our project at the end. We should’ve had a clear idea of what we needed to do to build our game instead of needing to change our game multiple times. 

 

Our user testing went decent, we had a lot of feedback, and we were certain we’d do well in the final presentation, but due to unanticipated circumstances, I was disappointed with how our final presentation ended out. We discovered that several of the servos had abruptly stopped working due to a broken wire, which was the primary reason one of the zombies failed to operate. However, we now know to double-check and test our project to avoid  unforeseen events. I believe that this endeavor has given us a tremendous deal of insight into what to avoid doing. We obtained more coding expertise and discovered a lot about our potential. We can improve the next time by using these lessons. We have complete control over the final project’s outcome, and we intend to employ what we’ve learned in the midterm as effectively as we can on our final.

One thought on “Midterm Interaction Lab”

Leave a Reply

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