Final Report- lane Berat- professor Gottfried

Video of project: https://drive.google.com/file/d/1wsDYRtt9Grp1dwJQdrg7QNlAcyg5AzhN/view?usp=drive_link  Pictures: https://drive.google.com/drive/folders/136ErxayROmh7NFy3GQV93D6ZPThRfmBz?usp=drive_link 

Final Report

The design and development of the “Campus Cruiser” project were significantly influenced by user interactions and feedback. This project centered around an Arduino-controlled vehicle with two DC motors and an H-bridge for bidirectional wheel movement, utilizing a joystick for navigation and an ultrasonic sensor to avoid obstacles from dorms to school. The initial concept was to mimic the NYU bus, which was integral to the thematic alignment of the design.
Understanding how users would interact with the Campus Cruiser was crucial. The use of a joystick for control was a design choice aimed at simplifying the driving mechanism, making it intuitive and user-friendly. This decision was reinforced during user testing sessions where the immediate and natural use of the joystick by testers validated its effectiveness as a control tool.
Another significant design decision was the incorporation of a joystick holder to enhance user experience. This idea emerged from user feedback during testing sessions, where the absence of a holder led to slight operational inconvenience. Responding to this, a 3D-printed joystick holder was developed and integrated, which not only improved the aesthetics but also the functionality, making the joystick more stable and easier to operate.
Another change we made based on user testing was when a professor pointed out that the vehicle’s design did not convincingly represent an NYU bus, thus diluting the thematic relevance of the project which we also changed and built a new bus using the laser cutter.

We used a joystick for our project to control how the car moved we felt this was the best option because the other option we thought of was using Bluetooth but felt it would be too hard and not have enough time to make sure it would work the way we wanted. DC motors were also used I researched Arduino cars and most of the motors used were DC motors so that is why we chose those motors. We used Hbridge for our motors to move in both directions because it was suggested by our professor and fit well with our project. we used ultrasonic sensors to detect if the car had hit anything we used these sensors because we found buttons were not sensitive enough. We were going to add two ultrasonic sensors but when we attached the second sensor our code would not work even after help from a professor so we decided to stick with one. We then added LEDs to our NYU bus to incorporate processing in our project when the bus is driving and does not detect anything using a sensor it stays purple and has a song playing and when it detects something it turns red and a crash sound is played.
The coding process of our car went smoothly we started with a code I wrote based on a code from one of the LAs than my partner rewrote it to another code because we were having issues with the code not working well with two motors. We had some help from an LA and a professor.

The goal of our project was to build a car that avoids obstacles in some way and I believe that we met our goal of our project idea. Both me and my partner worked well together during the building process of our final project which we learned from our midterm, especially with prototyping, incorporating user feedback, building, dividing work among us, and time management. The project demonstrated the importance of user-centered design and iterative feedback processes in creating effective and engaging educational tools. The accomplishments of this project, particularly in how effectively it engaged users and incorporated their feedback into the design process.

Joystick and motor code:
// joystick
#define VRX_PIN A0 // Arduino pin connected to VRX pin
#define VRY_PIN A2 // Arduino pin connected to VRY pin (issue with A1 pin?)

 

//joystick
int xValue = 0; // To store value of the X axis
int yValue = 0; // To store value of the Y axis

// Motor A connections
int enA = 9;
int enB = 10;
int in1 = 5;
int in2 = 6;
int in3 = 3;
int in4 = 4;

void setup() {
// Set all the motor control pins to outputs
Serial.begin(9600);
// Set all the motor control pins to outputs
pinMode(enA, OUTPUT);
pinMode(enB, OUTPUT);
//left
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
//right
pinMode(in3,OUTPUT);
pinMode(in4,OUTPUT);

 

// Turn off motors – Initial state
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
}

void loop()
{

 

//joystick
// read analog X and Y analog values
xValue = analogRead(VRX_PIN);
yValue = analogRead(VRY_PIN);
// print data to Serial Monitor on Arduino IDE
//Serial.print(“x = “);
//Serial.print(xValue);
//Serial.print(“, y = “);
//Serial.println(yValue);

directionControl();
}

void directionControl() {
int speedA = 0;
int speedB = 0;
int tempX = map(xValue,0,1023,-10,10);
int tempY = map(yValue,0,1023,-10,10);
Serial.print(“tempX = “);
Serial.print(tempX);
Serial.print(“, tempY = “);
Serial.println(tempY);

if (abs(tempX) < 2 && abs(tempY) < 2) {
Serial.println(“Stop”);
} else if (abs(tempX) > abs(tempY)) {
if (tempX > 0) {
Serial.println(“Left”);
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
speedA = 70;
speedB = 70;
} else {
Serial.println(“Right”);
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);

PROCESSING CODE:
import processing.serial.*;
import processing.sound.*;

Serial serialPort;
SoundFile sound;
SoundFile crash;

int NUM_OF_VALUES_FROM_ARDUINO = 3; /* CHANGE THIS ACCORDING TO YOUR PROJECT */
/* This array stores values from Arduino */
int arduino_values[] = new int[NUM_OF_VALUES_FROM_ARDUINO];

 

void setup() {
size(500, 500);
background(0);

sound = new SoundFile(this, “mariobros.mp3”);
crash = new SoundFile(this, “crash.mp3”);
sound.loop();

printArray(Serial.list());
// put the name of the serial port your Arduino is connected
// to in the line below – this should be the same as you’re
// using in the “Port” menu in the Arduino IDE
serialPort = new Serial(this, “/dev/cu.usbmodem14301”, 9600);
}

void draw() {
background(0);
stroke(255);
fill(255);

// receive the values from Arduino
getSerialData();

// use the values like this:
float x = map(arduino_values[0], 0, 1023, 0, width);

// here you play sounds if (
float y = map(arduino_values[1], 0, 1023, 0, height);

if (arduino_values[2] <5 ) {
println(“play crash”);
crash.play();
}
rectMode(CENTER);
rect(width/2, height/2, x, y);
}

 

// the helper function below receives the values from Arduino
// in the “arduino_values” array from a connected Arduino
// running the “serial_AtoP_arduino” sketch
// (You won’t need to change this code.)

void getSerialData() {
while (serialPort.available() > 0) {
String in = serialPort.readStringUntil( 10 ); // 10 = ‘\n’ Linefeed in ASCII
if (in != null) {
print(“From Arduino: ” + in);
String[] serialInArray = split(trim(in), “,”);
if (serialInArray.length == NUM_OF_VALUES_FROM_ARDUINO) {
for (int i=0; i<serialInArray.length; i++) {
arduino_values[i] = int(serialInArray[i]);
}
}
}
}
}

 

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.