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 p5:

For this exercise, I kept the arduino code the same as the one in the example and I expanded on the p5js code in the example to include input from the 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. 

/* Week 11.2 bidi serial example
 * Originally by Aaron Sherwood
 * Modified by Mangtronix
 * Modified further by Mirette Dahab
 *
 * Add this library to Sketch files
 *  https://github.com/mangtronix/IntroductionToInteractiveMedia/blob/master/code/p5.web-serial.js files
 *
 * You must include this line in your index.html (in Sketch Files) to load the
 * web-serial library
 *
 *     <script src="p5.web-serial.js"></script>
 *
 * Arduino code:
 * https://github.com/mangtronix/IntroductionToInteractiveMedia/blob/master/code/Week11Serial.ino
 */

let Y = 0;
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() {
  // one value from Arduino controls the background's red color
  background(255);
  fill(255,0,0);
  ellipse(map(X, 0, 1023, 0, width), 220, 100);

  // the other value controls the text's transparency value
  // fill(255, 0, 255, map(alpha, 0, 1023, 0, 255));

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


  // click on one side of the screen, one LED will light up
  // click on the other side, the other LED will light up
  if (mouseIsPressed) {
    if (mouseX <= width / 2) {
      left = 1;
    } else {
      right = 1;
    }
  } else {
    left = right = 0;
  }
}

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

  1. make something that controls the LED brightness from p5

for this exercise, I created a short program that allows the user to control the brightness by moving the mouse around the screen, each area in the screen has a different brightness value assigned and the value is sent to the arduino to light up the led as expected.

p5js:

let brightnessVal= 0;

function setup() {
  createCanvas(400, 400);
  background(220);
}

function draw() {//control the brightness value according to the placement of the mouse on the x axis
  if(mouseX >= 0 && mouseX <= 100){
      brightnessVal = 0;
  }else if(mouseX > 100 && mouseX <= 200){
      brightnessVal = 50;
  }else if(mouseX > 200 && mouseX <= 300){
      brightnessVal = 150;
  }else if(mouseX > 300 && mouseX <= 400){
      brightnessVal = 250;
  }
  // console.log(brightnessVal);
}

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

function readSerial(data) { //sends data to arduino
  let SentData = brightnessVal + ", \n";
  writeSerial(SentData);  
}

arduino:

const int RedledPin = 5;  // assign the pin for the LED

void setup() {
  pinMode(RedledPin, OUTPUT);
  Serial.begin(9600);// Start serial communication
}

void loop() {
  Serial.println("sensor");
  if (Serial.available() > 0) {  // Check if data is available from p5.js
    int brightnessVal = Serial.parseInt();   // Read value from p5.js
    analogWrite(RedledPin, brightnessVal);
  }
}

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

For this exercise, I extended the example given by creating an OnOff variable that would store whether or not the ball is hitting the ground or not and sending it to the arduino to control the LED. I also read input from the potentiometer and stored it in the wind.x variable so that it controls the wind.

 

p5js:

let velocity;
let gravity;
let position;
let acceleration;
let wind;
let drag = 0.99;
let mass = 50;
let OnOff = 0;

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);
  applyForce(wind);
  applyForce(gravity);
  velocity.add(acceleration);
  velocity.mult(drag);
  position.add(velocity);
  acceleration.mult(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;
  }
  if(position.y == height-mass/2 && (velocity.y > 0.5 || velocity.y < -0.5)){ 
    OnOff = 1;
  }else{
    OnOff = 0;
  }
}

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 (keyCode == UP_ARROW) {
    // important to have in order to start the serial connection!!
    setUpSerial();
  }
  if (key==' '){
    mass=random(15, 80);
    position.y=-mass;
    velocity.mult(0);
  }
}

function readSerial(data) {

  if (data != null) {
    wind.x = data ;
    let sentData = OnOff + "\n";
    writeSerial(sentData);
  }
}

Arduino:

int ledPin = 5; 
int Potpin = A1;

void setup() {
  // Start serial communication so we can send data
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT); //set led for output
  pinMode(Potpin, INPUT);//set potentiometer for input
}

void loop() {
  int windsensor = analogRead(Potpin);//read data from the potentiometer
  int wind = map(windsensor, 0, 1023, -2, 2);
  delay(10);
  if (Serial.available() > 0) { //read data from p5js
    int Val = Serial.parseInt();
    digitalWrite(ledPin, Val);
  }
}

 

Week 11 : Final project

The idea is to create an interactive car simulator that combines P5 and Arduino. Users will be able to simulate driving a car on a computer screen by using physical gestures detected by Arduino sensors. I would like to incorporate features such as LEDs and a horn into the system using sensors. The system aims to provide an engaging and interactive experience, where users can control various aspects of the virtual car’s behavior through their movements. Users can control the virtual car using physical gestures detected by sensors connected to Arduino. This project emphasizes careful and timely sensing of the user’s actions, translating them into responsive and engaging interactions within the virtual car simulation. The goal is to create an immersive experience that involves a dynamic exchange between the user and the simulated car, making the interaction enjoyable and interactive.

Reading Reflection – Week #11

I was glad to read about the topic of design in the context of disability and how it has historically been approached with a focus on discretion rather than aesthetics or even functionality. I found the discussed collaboration between athlete and model Aimee Mullins and designer Alexander McQueen to be beautifully inspiring. It highlights the power of design and how it can be used to transform something that is considered a pitied disadvantage into an element of individual identity. It opens a completely new direction, one that values empowerment and personal expression rather than the wish to blend in and the strive for “normal”.

As we go deeper into this evolving conversation about design and disability, I’m left wondering about the potential effects on societal perceptions. How might a more widespread acceptance of visually expressive assistive devices lead to a more inclusive sense of beauty and ability? Can collaboration between designers and people with disabilities pave the way for a cultural shift towards celebrating uniqueness rather than conforming to preconceived norms? Storieslike the one of Aimee Mullins and Alexander McQueen invite to consider the transforming role of design not only in the lives of persons with disabilities, but also in constructing a more inclusive and welcoming society that celebrates the complexity of individual experiences.

Final Project Idea

Concept)
I still haven’t fully decided what I want to do for my final project, but I plan to have the main concept as ‘screaming.’ I created a game that required the player to scream and I really liked the concept. One thing I regret from last project is that if I made it so that the player would have to continue screaming in order to make the game playable (i.e. slower the speed), it would’ve made more sense. I think trying this approach in my final project would be nice.

I have two different types (still very general ideas) in mind.

One is a game that would have the goal of attacking (like aircraft wargame). In this case, I think I’ll give a gauge that can be filled up by screaming. Once the gauge is full, the player will be able to press the force sensor to use a booster. When this booster is used, the player will become invincible like players in mariokart when they have used starman (refer to the video below).

Second type is a more challenge-focused game without attacks. One example can be puzzle bubble. Also in this concept, I’ll have a gauge that makes the player scream. When the gauge is full, the player will be able to punch (or press) on the fore sensor. This will work as special item such as clearing 3 lines etc.

Although I’m still thinking about the general structure of the game, I have decided that I will make use of ‘screaming’ and ‘force sensor’ as the main theme of my game. By punching the force sensor, I mean something like below:

Implentation)

I think the first thing to do would be to get the general structure of the game decided. After that, I will decide how to make it clear that there’s a strong incentive for the player to scream and punch. I will first test simple codes with the sensors (arduino) separately, the p5js part separately, and then combine the two parts.

Week 11 – Reading Reflection

I really liked the approach of the reading. I think until now, based on the readings we’ve had, most of my  discussion on these posts and in class have been from a perspective that design tends to focus on a certain group of people- usually, the healthy and the capable. I remember multiple discussions I had with my classmates in our in-class discussion how different designs and pursuits of certain designs tend to leave out the minority. We had a shared emotion that this may be logical (from a company  or designer’s point of view) but such a sad downside of designs that pursue convenience or attractiveness.

I think this reading really makes us ask ourselves if really, a pursuit of something in a design means a give-up in other factors of a design, and if that’s ideal. One topic the reading looks at discretion and fashion. It talks about how they are concepts with tension, but not the opposite. I feel like there are some factors that we take to blindly think are at opposite ends and a pursuit of one means we would need to give up the other. I think as designers, one of our role is to realize such factors that are actually not at opposite ends and figure out how a design can pursue both (although there would be tension between them).

Final Project Idea

For the final project of this class, I have a lot of vague ideas but need to decide on one based on its practicality! I know what I want to use for the project but I’m trying to figure out if I want to make that in an interactive game form or an art form. Either an interactive art that takes input from the arduino through different body movements or a game that works on the same mechanism.

Things that I’m sure of:

  1. Including the whole body as a part of this as after the readings from this class, one of my biggest takeaways has been using the entire body or atleast just more than hands for creating an immersive experience.
  2. I want to try to use flex and force sensors since I’ve never had a chance to use them for the weekly assignments yet
  3. I’m a person who has the shortest attention span and loses interest very quickly so I want to make something that is long lasting fun and not something that looses it charm after 2 minutes.

Week 11: Final Project Idea

For my final project, I envision creating an immersive and interactive experience, a collaborative music jam that seamlessly combines Arduino gesture sensors with P5.js to transform hand movements into a dynamic and expressive musical journey. It will invite participants to engage in a unique music jam session where their gestures become the driving force behind the creation of a harmonious ensemble. Leveraging Arduino gesture sensors, the system will capture the nuances of users’ hand movements, translating them into musical notes or instrument selections in real-time through the P5.js environment.

Reading Reflection: Week 11

The reading offers a compelling intersection of disability, fashion and design. From my perspective, the narrative goes beyond mere functionality, delving into the core principles of inclusion and empowerment, particularly when viewed through the lenses of inclusivity and disability awareness.

Pullin skillfully demonstrates the evolution of assistive technology, including items like glasses and hearing aids, transcending their utilitarian roles to become symbols of fashion and personal identity. The transformation of these tools from mere aids to manifestations of individual style challenges the traditional notion that they are exclusively intended for individuals with particular disabilities.

He emphasizes the importance of designs that seamlessly blend functionality with aesthetic appeal. He underscores the significance of creating visually pleasing and accessible products for those with disabilities, shifting the narrative from mere utility to a combination of style and assistance. He stresses upon the value of maintaining functionality without compromising simplicity, asserting that such designs can benefit a broad spectrum of individuals, regardless of ability. 

The reading underscores the inclination to presume we understand what is optimal for individuals with disabilities, shaped by societal stigmas and preconceptions. Consequently, there is a critical need to concentrate on the nuanced aspects that not only improve our own lives but also profoundly influence the lives of those who stand as the primary recipients of these designs.

Week 11: Reading Response

“Design Meets Disability”:

While reading this chapter, one thing kept popping into my mind, the story of my best friend who was diagnosed with diabetes when she was 4. Growing up together, I got to witness all the phases she went through to accept her disability. Her biggest problem wasn’t the illness itself but rather the equipment she had to “wear” as medication. When she was first diagnosed she used to wear an insulin pump that looked like the one in the picture below, except hers had longer tubes and the proportion of the device to her little body was much bigger, so naturally it was very obvious and raised so many questions that she started getting very self-conscious about it because other children were pointing out that she was a robot or that she needed to be charged like their phones:

Fast forward a few years, her insulin pump was upgraded to this one, the Omnipod: 

The Omnipod is less obvious and is only visible if she is wearing short sleeved shirts, so it is easier for her to hide it when she wants to and display it when she desires. The change in her mental health was very obvious and she seemed to accept her illness more and slowly she started wearing tank tops to display her pump and show the world her “superpower” as she likes to call it. 

I have always wondered why they couldn’t have designed a smaller pump for little children, or made it look nicer so that they wouldn’t be ashamed of it or feel like outcasts wearing it. Lately I have been seeing ads of sticker packs and covers to “style” the Omnipod which makes me wonder if this would make little children more accepting of their illness and less of an outcast.

 

I have always believed that designers tend to not care about the implications of their design when it comes to designing for disabled people, because for them it’s a need not a want so they would accept whatever is given to them. It was nice to read about examples of design that are more inclusive and more thoughtful of disabled people’s feelings.

Week 11: Final project idea

Interactive drum kit

For my final project I would love to incorporate my love for music by creating a simulation of a drum kit. If possible, I would like to expand my drum kit to include different kits that could be changed by a click of a button on the arduino board. I would use force sensors on the arduino for the input from the users and generate a sound and a corresponding visual on the screen accordingly. When a user strikes one of the physical drum elements, the force sensor detects the impact, and the Arduino sends a signal to the P5.js application. The P5.js app responds by triggering the associated drum sound and displaying visual feedback. In a way to make my drum kit creative, I would like to create different drum kits that incorporate a collection of everyday sounds mixed to sound like a drum sounds.