Week 11 – In class exercises

  1. make something that uses only one sensor  on Arduino and makes the ellipse in p5 move on the horizontal axis, in the middle of the screen, and nothing on arduino is controlled by p5For this exercise, I modified the p5js code using a potentiometer on the arduino. Different values of the potentiometer are mapped to the x coordinates of the ellipse. This makes it move across the horizontal axis in the middle of the screen. The arduino code remains the same as the example code.
let y=height/2;
let x = 0;
let left = 0; // True (1) if mouse is being clicked on left side of screen
let right = 0; // True (1) if mouse is being clicked on right side of screen

function setup() {
  createCanvas(640, 480);
  textSize(18);
}

function draw() {
  background(255);
  // one value from Arduino controls the background's red color
  fill(255, 0, 255, map(x, 0, 1023, 0, 255));
  ellipse(map(x, 0, 1023, 0, width), 30, 30);

  // the other value controls the text's transparency value

  if (!serialActive) {
    text("Press Space Bar to select Serial Port", 20, 30);
  } else {
    text("Connected", 20, 30);
  }


 
function keyPressed() {
  if (key == " ") {
    // important to have in order to start the serial connection!!
    setUpSerial();
  }
}

// This function will be called by the web-serial library
// with each new *line* of data. The serial library reads
// the data until the newline and then gives it to us through
// this callback function
function readSerial(data) {
  ////////////////////////////////////
  //READ FROM ARDUINO HERE
  ////////////////////////////////////

  if (data != null) {
    // make sure there is actually a message
    // split the message
    let fromArduino = split(trim(data), ",");
    // if the right length, then proceed
    if (fromArduino.length == 2) {
      // only store values here
      // do everything with those values in the main draw loop
      
      // We take the string we get from Arduino and explicitly
      // convert it to a number by using int()
      // e.g. "103" becomes 103
      y = int(fromArduino[0]);
      x = int(fromArduino[1]);
    }

    //////////////////////////////////
    //SEND TO ARDUINO HERE (handshake)
    //////////////////////////////////
    let sendToArduino = left + "," + right + "\n";
    writeSerial(sendToArduino);
  }
}

2. make something that controls the LED brightness from p5

again tweaking the previous p5js and arduino codes, for this one, Pressing the up or down arrow key on the keyboard, run through p5js, increases or decreases the brightness of the leds on the arduino respectively. this was done using the concept of pulse width modulation.

p5js code:

let rVal = 0;
let alpha = 255;
let brightness = 0;

function setup() {
  createCanvas(640, 480);
  textSize(18);
}

function draw() {
  background(map(rVal, 0, 1023, 0, 255), 255, 255);
  fill(255, 0, 255, map(alpha, 0, 1023, 0, 255));

  if (!serialActive) {
    text("Press Space Bar to select Serial Port", 20, 30);
  } else {
    text("Connected", 20, 30);
    text('rVal = ' + str(rVal), 20, 50);
    text('alpha = ' + str(alpha), 20, 70);
  }
}

function keyPressed() {
  if (key == " ") {
    setUpSerial();
  } else if (keyCode === UP_ARROW) {
    brightness = constrain(brightness + 20, 0, 255);
    sendToArduino();
  } else if (keyCode === DOWN_ARROW) {
    brightness = constrain(brightness - 20, 0, 255);
    sendToArduino();
  }
}

function sendToArduino() {
  let sendToArduino = brightness + "\n";
  writeSerial(sendToArduino);
}

function readSerial(data) {
  if (data != null) {
    let fromArduino = split(trim(data), ",");
    if (fromArduino.length == 2) {
      rVal = int(fromArduino[0]);
      alpha = int(fromArduino[1]);
    }
    let sendToArduino = brightness + "," + brightness + "\n";
    writeSerial(sendToArduino);
  }
}



arduino code:

int leftLedPin = 2;
int rightLedPin = 5;

void setup() {
  // Start serial communication so we can send data
  // over the USB connection to our p5js sketch
  Serial.begin(9600);

  // We'll use the builtin LED as a status output.
  // We can't use the serial monitor since the serial connection is
  // used to communicate to p5js and only one application on the computer
  // can use a serial port at once.
  pinMode(LED_BUILTIN, OUTPUT);

  // Outputs on these pins
  pinMode(leftLedPin, OUTPUT);
  pinMode(rightLedPin, OUTPUT);

  // Blink them so we can check the wiring
  digitalWrite(leftLedPin, HIGH);
  digitalWrite(rightLedPin, HIGH);
  delay(200);
  digitalWrite(leftLedPin, LOW);
  digitalWrite(rightLedPin, LOW);

  // start the handshake
  while (Serial.available() <= 0) {
    digitalWrite(LED_BUILTIN, HIGH); // on/blink while waiting for serial data
    Serial.println("0,0"); // send a starting message
    delay(300);            // wait 1/3 second
    digitalWrite(LED_BUILTIN, LOW);
    delay(50);
  }
}
void loop() {
  // wait for data from p5 before doing something
  while (Serial.available()) {
    digitalWrite(LED_BUILTIN, HIGH); // led on while receiving data

    int left = Serial.parseInt();
    int right = Serial.parseInt();
    if (Serial.read() == '\n') {
      Serial.print("Left: ");
      Serial.print(left);
      Serial.print(", Right: ");
      Serial.println(right);

      analogWrite(leftLedPin, left);
      analogWrite(rightLedPin, right);
    }
  }
  digitalWrite(LED_BUILTIN, LOW);
}



3. take the gravity wind example (https://editor.p5js.org/aaronsherwood/sketches/I7iQrNCul) and make it so every time the ball bounces one led lights up and then turns off, and you can control the wind from one analog sensor

I found this one to be a little challenging but eventually made it work. the ball bounces with the same logic and physics from the example. Each time it touches the ground, using a boolean variable ballOnGround, it is equated to 1 or 0. this is then sent to the arduino where the LED turns on if it is 1. For the sensor contrilling wind, Im using a photoresitor whose values are mapped to the x coordinate of the wind vector. The ball moves faster when the value is larger. MouseClicking restarts the movement of the ellipse. The issue I face is slight delay in the led lighting up.

video:

p5.js Code:

let velocity;
let gravity;
let position;
let acceleration;
let wind;
let drag = 0.99;
let mass = 20;
let ballOnGround=1;
function setup() {
  createCanvas(640, 360);
  noFill();
  position = createVector(width/2, 0);
  velocity = createVector(0,0);
  acceleration = createVector(0,0);
  gravity = createVector(0, 0.5*mass);
  wind = createVector(0,0);
}

function draw() {
  background(255);
  
  if (!serialActive) {
    text("Press Space Bar to select Serial Port", 20, 30);
  } else {
    applyForce(wind);
    applyForce(gravity);
    velocity.add(acceleration);
    velocity.mult(drag);
    position.add(velocity);
    acceleration.mult(0);

    fill(0);
    ellipse(position.x, position.y, mass, mass);
    if (position.y > height - mass / 2) {
      velocity.y *= -0.9; // A little dampening when hitting the bottom
      position.y = height - mass / 2;
      ballOnGround = 1;
      let sendToArduino = ballOnGround + "\n";
    writeSerial(sendToArduino);
    ballOnGround = 0;
    sendToArduino = ballOnGround + "\n";
    writeSerial(sendToArduino);
    } else {
      ballOnGround = 0;
    }
  }
  
  
  if (mouseIsPressed) {
      restartSketch();
    }
}

function applyForce(force){
  // Newton's 2nd law: F = M * A
  // or A = F / M
  let f = p5.Vector.div(force, mass);
  acceleration.add(f);
}


function keyPressed() {
  if (key == " ") {
    // important to have in order to start the serial connection!!
    setUpSerial();
  } 
}

function readSerial(data) {
  if (data != null) {
    // make sure there is actually a message
    // split the message
    let fromArduino = split(trim(data), ",");
    // if the right length, then proceed
    if (fromArduino.length == 1) {
      // only store values here
      // do everything with those values in the main draw loop
      let photoresistor = int(fromArduino[0]);
      
      //change the wind based on the photoresistor readings
      wind.x = map(photoresistor, 0, 1000, -5, 5);
      
    }

    //////////////////////////////////
    //SEND TO ARDUINO HERE (handshake)
    //////////////////////////////////
    // let sendToArduino = ballOnGround + "\n";
    // writeSerial(sendToArduino);
  }
}


function restartSketch() {
  // Reset relevant variables to their initial values
  position = createVector(width / 2, 0);
  velocity = createVector(0, 0);
  acceleration = createVector(0, 0);
  wind = createVector(0, 0);
  mass = 50;
  ballOnGround = 0;
}

arduino code:

int ledPin = 2;
const int photoresistorPin = A0;

void setup() {
  Serial.begin(9600);
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(ledPin, OUTPUT);
  pinMode(photoresistorPin, INPUT);

  // start the handshake
  while (Serial.available() <= 0) {
    digitalWrite(LED_BUILTIN, HIGH); // on/blink while waiting for serial data
    Serial.println("0,0");           // send a starting message
    delay(300);                      // wait 1/3 second
    digitalWrite(LED_BUILTIN, LOW);
    delay(50);
  }
}

void loop() {
  // wait for data from p5 before doing something
  while (Serial.available()) {
    digitalWrite(LED_BUILTIN, HIGH); // led on while receiving data
    int ballOnGround = Serial.parseInt();
    if (Serial.read() == '\n') {
      int photoresistorValue = analogRead(photoresistorPin);

      // Send photoresistor value to p5.js
      Serial.println(photoresistorValue);
      digitalWrite(ledPin, HIGH);
      digitalWrite(ledPin, LOW);
      // Control the LED based on the bouncing state.
      if (ballOnGround == 1) {
        digitalWrite(ledPin, HIGH);
      } else {
        digitalWrite(ledPin, LOW);
      }
    }
  }
  digitalWrite(LED_BUILTIN, LOW);
}

 

Reading Reflections – Week 11!

After this thought-provoking read, I wholeheartedly feel that a design should be universally accessible, catering to everyone’s needs. Imagine the convenience of a singular product that eliminates the need for individuals to ponder, “Will this suit my requirements?” or “Is this tailored for a specific group?” Although implementing such universality might pose challenges for designers, the benefits could be substantial.

This approach would eradicate the apprehension associated with designing for differently-abled individuals, as it wouldn’t be perceived as mediocre or subpar when designed for a broader audience. The return of a sense of ‘delight’ in everyday products could be achieved through a more inclusive design, fostering unity rather than segregation. While certain disabilities may require specialized technology, there are aspects we can universalize for everyone.

What particularly intrigued me is the question of whether we should project a positive image or refrain from projecting an image altogether. Striking a balance that avoids exclusion and encourages accommodation is crucial. Examples related to fashion, discretion, and simplicity prompted me to contemplate how, as someone pursuing interactive media, I can contribute to bridging the gap between realism and functionalism. The oldest ipod nano that my father owned used to be my favorite device. The familiarity of the tracker wheel mentioned in the text resonates with me.

Reflecting on my five-year-old self effortlessly navigating it, I realize the design and feedback were exceptionally well-executed. It serves as a possibility of achieving a harmonious intersection of simplicity, functionality, and aesthetics—providing inspiration for designers and me, particularly to aim to strike that delicate balance.The idea of embracing cultural differences in embracing fashion and technology did sound a little strange at first but I agree that it would definitely be a call to action for more innovative and accessible design.

Week 11 | Final Project Idea

The concept

Embarking on the final project, my vision is to delve into the realms of robotic design and control, materializing as a remotely operated car crafted with P5JS. This innovative creation aims to seamlessly integrate a webcam, offering users a live, visual stream on P5JS that transcends physical boundaries, enabling intuitive remote navigation, even when the car finds itself in a distant locale. A noteworthy feature includes the incorporation of a distance sensor, placed to alert users and avoid potential collisions, enhancing the overall safety and user experience.

The broader implications of this project are both captivating and practical. Beyond the realms of a mere technological endeavor, this remotely controlled car carries the potential to be a transformative tool. One significant application lies in aiding individuals with limited mobility, serving as a conduit for them to virtually traverse diverse spaces.

Week 11 | Reading Reflection

The reading looks into the complicated world of inclusive design, examining the obstacles and trade-offs involved in developing products that appeal to a wide range of abilities and needs. The conflict between universality and simplicity is a reoccurring subject, presenting serious concerns about the delicate balance required to achieve both accessible and user-friendly designs.

One argument highlights the difficulties and conflicts involved in designing for disability, especially in the context of universal or inclusive design. On one hand, there’s a commercial rationale for not fragmenting the market by developing specialized designs for tiny populations. In contrast, inclusive design seeks to meet the unique needs and goals of the whole population while taking into account varying abilities and preferences. I see that inclusive design is a good approach designers should always seek regardless of the financial objectives. I feel like it’s our commitment to create products and environments that are welcoming and functional for a diverse range of individuals. We don’t always have to choose between simplicity and universality; instead, we might achieve a balance that meets both needs. I think that Apple’s invention of the iPod device is a good example of this balance.

The reading also looks at examples of radios developed for specific purposes, such as assisting dementia patients. It highlights the importance of design in developing things that are not only usable but also aesthetically beautiful and emotionally engaging, even for those who have cognitive challenges. For me, it is not only about design, but about enhancing the quality of life and making daily experiences accessible for everyone.

Final Project Idea

Concept:

The idea is to create a “Crack The Code Safe Game.” There will be a locked mini safe box that the user will need to open by solving a simple math problem on the computer, revealing a secret 4-digit code.

This inspiration came from watching a video about a similar project: Crack The Code Safe.

Components:

  1. Handmade safe box:
    • This box has a lock controlled by an Arduino.
    • There’s a dial on the box connected to the Arduino that the user will use to enter the secret 4-digit code.
  2. Arduino:
    • The Arduino checks if the entered code is correct.
    • It manages locking and unlocking the safe.
  3. p5.js game interface:
    • It’s a simple math game on the computer screen (p5.js). This game helps the user find the 4-digit code for the safe.

User Experience Flow:

  1. Introduction: The user will receive instructions on how to open the safe, both on the computer screen and the safe box. The safe will have different codes for each new game. The user will be able to restart game. But the user cannot see the correct code without at least making one attempt to open the safe.
  2. Gameplay: The user will start playing the game on the computer. Each correct math problem solution reveals a digit of the secret 4-digit code in order. In other words, the user will solve 4 math problems and the answer to each problem is the digits of the secret code.
  3. Code Entry: The user solve the math problem, get a digit, and enter it using the dial on the safe box. Turn the dial to select digits and push it to confirm each one.
  4. Feedback and Unlocking: The Arduino checks the entered code. If it’s right, the safe unlocks, and the user win! If not, the game starts over, and a new secret code will be created.

Week 11 – Reading

The debate between functionality and design has always been an interesting one, and though sometimes it feels like you can only pick one without compromising both, it is very much possible to accomplish both as what Apple did with the iPod. Though most engineers might argue for the case of functionality, I think one very beautiful part of the shared human experience is that humans appreciate beautiful things like a sunset or a well-designed product. Donald Norman has a teapot that is functionally unusable, yet has a place on his countertop because he likes how it looks. Perhaps not everyone is as invested in design as Donald Norman is, that they would give up all functionality for design, but a case can be made for ‘functional enough’ before people start looking at design. Ten different tote bags are functionally all the same, but there might be one specific tote that a person might gravitate to more often. A tote bag with a hole might not be used because it does not perform it’s function well even if it is well-designed, but other than that, the tote bag that is chosen is the one that suits the dress code the best.

In the case of disability, it is a little strange that design for disability has always been about ‘catching up to a normal human’, and not augmenting them to beyond the capabilities of an average person. Why are leg prosthetics designed to look like bad imitations of flesh, when it could be used as a fashion accessory that able-bodied people are not able to? Why not design hearing aids that can enable superhearing? An able-bodied person is not the standard, and it is always an option to design beyond that, to make disability less of a stigma and instead become something that opens up new possibilities instead of reducing them. Prosthetic covers: Interview with Emelie Strömshed from Anatomic Studios - theactiveamputee

week 11: reading reflection

The reference to Charles Eames really stuck with me. “Design depends largely on constraints” — I think so too. What is good design if not bad design? It is easy to define bad design. It’s a jumble of elements that do not fit together, but forced into a whole that bears a discordant existence. Good design on the other hand, seems harder to articulate, but what cannot be told can be suggested, which seems to be Pullin’s standpoint as he enters the discussion of designing for special needs. Discretion has been appreciated as a design element when designing for disability, but, on the other hand, in the case of eyewear, there is an existing positive image, and so invisibility is not necessarily a consideration here. This is understandable; that every product has a different context surrounding itself and its design should be in accordance. But then Puliln also says, “fashion can be understated, and discretion does not require invisibility.” The discussion that follows illustrates how several parameters interact in defining the constraints of design, and the design of something transcends the thing itself and blends into people’s perception of other, related concepts, as is in the case of the design of eyewear and fashion.

Week 11 – Reading Response

The reading about design and disability really got me thinking. It showed how something as simple as fashion can change how we view things like glasses or other aids for individuals with disabilities. I used to wonder how glasses became a style statement, making people proud to wear them unlike other kinds of devices such as hearing aids. However, I particularly appreciate that the author addresses these devices as earwear and bodywear. They’re just something that people wear like clothes, and those devices hold very sentimental details for the designer, which shouldn’t make the individual feel odd or unusual.

The example of Aimee Mullins is especially an inspiring example that shows how prosthetic legs can be a way to express oneself, which is pretty amazing. It further illustrates how fashion can help designers make special aid devices more normalized and less visible, reducing the stigma of disability.

The main idea that I really liked about this reading is how design can make a huge difference for people with disabilities. Design isn’t just about making things look good; it’s about making life easier and more inclusive for them. Fashion can play a role in making people feel confident about using assistive devices. And when designs are simple, they make life easier for everyone, not just those with disabilities. The idea that simple designs work better, like what Apple does, totally makes sense. Simple things are easier for everyone to use, regardless of age or abilities of individuals. The reading discussed how it’s sometimes better to make designs specifically for one person instead of trying to make something that accommodates everyone.

Week 11 – Production

Teammate: Jiho

1st exercise: 
We used the existing example: Week 11 Bidirectional serial communication(p5js Sketch) to fulfill the 1st exercise. We created a new variable “moveEllipse” to map the alpha value to the canvas width. We then used our variable as the x-position of the ellipse, successfully enabling the ellipse to move from one edge to the other as the potentiometer value increased.

let moveEllipse = map(alpha, 0, 1023, 0, width);
stroke(0);
ellipse(moveEllipse, height / 2, 60);

 

2nd exercise:
Editing that same example, we added the bouncing ball javascript from p5.js: https://editor.p5js.org/icm/sketches/BJKWv5Tn . The LED becomes brighter when the ball moves towards the right edge of the canvas. Conversely, the LED becomes dimmer when the ball moves towards the left edge of the canvas. We edited the arduino to replace digitalWrite with AnalogWrite to enable the control of the LED brightness.

let x = 320;
let y = 180;
let xspeed = 3;
let yspeed = 2;
let r = 25;

ellipse(x, y, r*2, r*2);
// mapping brightness to canvas width
let rightValue = map(x, 0, width, 0, 255);
right = int(rightValue);

x += xspeed;
y += yspeed;
if (x > width - r || x < r) {
xspeed = -xspeed;
}
if (y > height - r || y < r) {
yspeed = -yspeed;
}
}

 

3rd exercise: https://youtu.be/YFucULMGidI

I took the main structure of the code from the exercise we looked at in class- where we had to press our spacebar to connect to our board. There, I added the code with the bouncing ball given to us through this link(https://editor.p5js.org/aaronsherwood/sketches/I7iQrNCul).

The approach was to call bounceBall() function once the serial is activated, where p5js will continuously send touch value (1 means it touched the ground and 0 means it’s above ground) to the arduino. In return, the arduino would send lightStatus value (the input read from the light sensor). If the received value is bigger than 500, the wind blows from left to right and right to left if below.

Below are parts of code that highlights the appraoch:
P5js

if (position.y > height-mass/2) {
      velocity.y *= -0.9;  // A little dampening when hitting the bottom
      position.y = height-mass/2;
    touch = 1;
    //////////////////////////////////
    //SEND TO ARDUINO HERE (handshake)
    //////////////////////////////////
    let sendToArduino = touch + "\n";
    console.log(touch);
    writeSerial(sendToArduino);
    touch = 0;
    sendToArduino = touch + "\n";
    writeSerial(sendToArduino);
    }

Arduino

int ledPin = 5;
int lightPin = A1;
int lightStatus;

void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  pinMode(lightPin, INPUT);

  // start the handshake
  while (Serial.available() <= 0) {
    digitalWrite(LED_BUILTIN, HIGH);
    Serial.println("0");
    delay(1000);
    digitalWrite(LED_BUILTIN, LOW);
    delay(100);
  }
}

void loop() {
  while (Serial.available()) {
    digitalWrite(ledPin, HIGH);

    int ledLight = Serial.parseInt();
    lightStatus = analogRead(lightPin);
    if (Serial.read() == '\n') {
      digitalWrite(ledPin, ledLight);
      delay(50);
      digitalWrite(ledPin, LOW);
      Serial.println(lightStatus);
      delay(5);
    }
  }
  digitalWrite(LED_BUILTIN, LOW);
}

 

week 11 – group assignment (maya)

1st exercise: 
We used the existing example: Week 11 Bidirectional serial communication(p5js Sketch) to fulfill the 1st exercise. We created a new variable “moveEllipse” to map the alpha value to the canvas width. We then used our variable as the x-position of the ellipse, successfully enabling the ellipse to move from one edge to the other as the potentiometer value increased.

let moveEllipse = map(alpha, 0, 1023, 0, width);  
//
stroke(0);
ellipse(moveEllipse, height / 2, 60);

2nd exercise:
Editing that same example, we added the bouncing ball javascript from p5.js: https://editor.p5js.org/icm/sketches/BJKWv5Tn . The LED becomes brighter when the ball moves towards the right edge of the canvas. Conversely, the LED becomes dimmer when the ball moves towards the left edge of the canvas. We edited the arduino to replace digitalWrite with AnalogWrite to enable the control of the LED brightness.

//
let x = 320;
let y = 180;
let xspeed = 3;
let yspeed = 2;
let r = 25;

//
  ellipse(x, y, r*2, r*2);
  // mapping brightness to canvas width
  let rightValue = map(x, 0, width, 0, 255);
  right = int(rightValue);
  //
  x += xspeed;
  y += yspeed;
  if (x > width - r || x < r) {
    xspeed = -xspeed;
  }
  if (y > height - r || y < r) {
    yspeed = -yspeed;
  }
}

3rd exercise: https://youtu.be/YFucULMGidI

I took the main structure of the code from the exercise we looked at in class- where we had to press our spacebar to connect to our board. There, I added the code with the bouncing ball given to us through this link: https://editor.p5js.org/aaronsherwood/sketches/I7iQrNCul

The approach was to call bounceBall() function once the serial is activated, where p5js will continuously send touch value (1 means it touched the ground and 0 means it’s above ground) to the arduino. In return, the arduino would send lightStatus value (the input read from the light sensor). If the received value is bigger than 500, the wind blows from left to right and right to left if the value is smaller than 500.

arduino:

int ledPin = 5;
int lightPin = A1;
int lightStatus;

void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  pinMode(lightPin, INPUT);

  // start the handshake
  while (Serial.available() <= 0) {
    digitalWrite(LED_BUILTIN, HIGH);
    Serial.println("0");
    delay(1000);
    digitalWrite(LED_BUILTIN, LOW);
    delay(100);
  }
}

void loop() {
  while (Serial.available()) {
    digitalWrite(ledPin, HIGH);

    int ledLight = Serial.parseInt();
    lightStatus = analogRead(lightPin);
    if (Serial.read() == '\n') {
      digitalWrite(ledPin, ledLight);
      delay(50);
      digitalWrite(ledPin, LOW);
      Serial.println(lightStatus);
      delay(5);
    }
  }
  digitalWrite(LED_BUILTIN, LOW);
}