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]);
}
}
}
}
}