Music Instrument

Concept:

I think it was a challenge for us to find an idea for this project. Alex and I shared some videos of cool musical instruments with one another. We also tried to brainstorm some ideas and think of how to do it. We wanted to do something interesting, and creative. After a series of discussions, we finally decided to make a flower and bee instrument. This instrument plays different sounds if the bee comes to a flower, or if sunlight is pointed at a flower. Also, it plays sound when the bee is going to the flower. We did this by making a circuit that had a toggle switch, an LED, four light sensors, one distance sensor, and a piezo buzzer. Would it be cool if one could hear sounds emitted by a flower under different conditions?

Our instrument makes different notes with the interaction between the flower, bee, and light, which I like to think of as a musical narrative that delves into the natural world.

Highlight:

 We began by assembling the circuit and making the flower, bees, and light source.

It was confusing to make the circuit, but it worked out fine in the end. We decided to add a toggle switch to move from the distance sensor to the light sensor, this enhanced the user experience by allowing them to transition between the distance sensor and the light sensors. The light sensor and the distance sensor add different interactive experiences for the user, which I think engages them more.

#include "pitches.h"

const int BUZZER = 8;
const int ECHO_PIN = 9;
const int TRIG_PIN = 10;
const int FLOWER1 = A0;
const int FLOWER2 = A1;
const int FLOWER3 = A2;
const int FLOWER4 = A3;
const int SWITCH = A5;
int flowerSound = 0;
int LED=2;
long duration = 100;

int DARK_THR = 600;

void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  pinMode(FLOWER1, INPUT);
  pinMode(FLOWER2, INPUT);
  pinMode(FLOWER3, INPUT);
  pinMode(FLOWER4, INPUT);
  pinMode(BUZZER, OUTPUT);  
  pinMode(ECHO_PIN, INPUT);    // echo pin measure the duration of pulses coming back from the distance sensor
  pinMode(TRIG_PIN, OUTPUT);   // trigger pin output pulses of electricity
  pinMode(LED,OUTPUT);
}

void loop() {
  digitalWrite(LED,HIGH);
  int flower1 = analogRead(FLOWER1);
  delay(1);  // delay in between reads for stability
  int flower2 = analogRead(FLOWER2);
  delay(1);  // delay in between reads for stability
  int flower3 = analogRead(FLOWER3);
  delay(1);  // delay in between reads for stability
  int flower4 = analogRead(FLOWER4);
  delay(1);  // delay in between reads for stability
  int switchOn = digitalRead(SWITCH);
  delay(1);  // delay in between reads for stability

  // Serial.println(switchOn);  ///debugging

  if (switchOn) {
    //dark sensor = lower notes
    if (flower1 <= DARK_THR) {
      tone(BUZZER, NOTE_C3, duration);
    } else if (flower2 <= DARK_THR) {
      tone(BUZZER, NOTE_D3, duration);
    } else if (flower3 <= DARK_THR) {
      tone(BUZZER, NOTE_E3, duration);
    } else if (flower4 <= DARK_THR) {
      tone(BUZZER, NOTE_F3, duration);

    //bright sensor = higher notes
    } else if (flower1 >= 850) {
      tone(BUZZER, NOTE_G3, duration);
    } else if (flower2 >= 850) {
      tone(BUZZER, NOTE_A3, duration);
    } else if (flower3 >= 850) {
      tone(BUZZER, NOTE_B3, duration);
    } else if (flower4 >= 850) {
      tone(BUZZER, NOTE_C4, duration);
    } else {         
      noTone(BUZZER);
    }
  } else { // if switch is changed to distance sensor
    int distance = getDistance();
    Serial.println(distance);
    if (1 < distance && distance < 3) {
      tone(BUZZER, NOTE_C4);
    } else if (3 < distance && distance < 6) {
      tone(BUZZER, NOTE_D4);
    } else if (6 < distance && distance < 9) {
      tone(BUZZER, NOTE_E4);
    } else if (9 < distance && distance < 12) {
      tone(BUZZER, NOTE_F4);
    } else if (12 < distance && distance < 15) {
      tone(BUZZER, NOTE_G4);
    } else if (15 < distance && distance < 18) {
      tone(BUZZER, NOTE_A4);
    } else if (18 < distance && distance < 21) {
      tone(BUZZER, NOTE_B4);
    } else {
      noTone(BUZZER);
    }
  }
}

float getDistance() {
  float echoTime;                   //variable to store the time it takes for a ping to bounce off an object
  float calculatedDistance;         //variable to store the distance calculated from the echo time

  //send out an ultrasonic pulse that's 10ms long
  digitalWrite(TRIG_PIN, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIG_PIN, LOW);

  echoTime = pulseIn(ECHO_PIN, HIGH);      //pulsein command to see how long it takes for pulse to bounce back to sensor
  calculatedDistance = echoTime / 55.2;    //calculate  distance of object that reflected the pulse in cm 
  return calculatedDistance;  
}

 

The code was simple, we created a nested if condition so that when the switch is on the light sensors (the flowers) would play different notes. The notes change in pitch from low to high depending on whether the bee is on the flower of the light source. Then when the switch is off we move to the distance sensor where the bee moves displaying different sounds. These notes are played with a difference of 3cm in distance. For the distance sensor, we play a whole octave of notes.

 

 Reflection and Future Improvements:

 I enjoyed making this assignment, but I believe there is room for improvement. There is much more that can be done and improved so that the sound is clearer, and the instrument is more interesting. It would be cool if it were a dual-player instrument, which means that the distance sensor and the light sensor play the sounds at the same time. It is a little more complicated to do and would need more time. On the aesthetics aspect, canceling all the wires in a box would be neater, and safer for users, thus providing an appealing look. I believe there is space to enhance this project in terms of functionality and look; however, this project was a challenge technically but sparked our imagination.

Week 10 – Musical Instrument

Cat Composer

By Sneheel & Angela

Concept:

While working on this project, we went over several ideas on how we would make an instrument. One thing we discovered in our ideation process was that both of us had previously made projects that centrally involved cats. Thus, with some more tinkering around – we came up with “The Cat Composer”! The Cat Composer is an all in one musical instrument that can play a variety of simple tunes such as “Hot Cross Buns” and “Mary Had a Little Lamb”. It consists of 2 switches to control 2 beat-making servo motors, a distance sensor to control the notes (C, D, E, and G), and a turning potentiometer to toggle between octaves. Additionally, we incorporated a speaker from the IM Lab inventory to make a better sound than the provided buzzer. This instrument is best played with two people, one to play percussion/toggle between octaves, and one to play the notes.

However, with a bit of practice it is completely possible to play it by oneself! Note: In order for the distance sensor to receive a steady input and play the correct notes, it is best to play not with one’s hands, but with a larger piece of material.

Demonstration Video

Code & Highlights:

The toughest part in the coding process was to ensure that the distance sensor worked exactly as we intended. For example, an issue that we ran into early was the abrupt changing of tune at the border values. Since the sensor isn’t accurate to the exact cm. It would then fluctuate between two tunes. We corrected this by instead using a 5-value moving average. This makes transitions significantly smoother (and the experience much more enjoyable!!)

unsigned int measureDistance() {
  const int numReadings = 5;  // Number of readings to average
  const int maxChange = 150;   // Maximum acceptable change in cm between readings
  static unsigned int lastAverage = 0;  // Store the last valid average distance
  unsigned long totalDuration = 0;


  for (int i = 0; i < numReadings; i++) {
    digitalWrite(trigPin, LOW);
    delayMicroseconds(2);
    digitalWrite(trigPin, HIGH);
    delayMicroseconds(10);
    digitalWrite(trigPin, LOW);


    totalDuration += pulseIn(echoPin, HIGH);
    delay(10); // Short delay between readings
  }


  unsigned int currentAverage = (totalDuration / numReadings) * 0.034 / 2;


  // Check if the change from the last average is within the expected range
  if (abs((int)currentAverage - (int)lastAverage) <= maxChange || lastAverage == 0) {
    lastAverage = currentAverage;  // Update the last valid average
    return currentAverage;
  } else {
    return lastAverage;  // Return the last valid average if the current reading is an outlier
  }
}

Room for improvement:

We can improve our project significantly given more time!

Firstly, we would love the diversify the sounds our project can generate. In our research we discovered that instead of simply using tone() we could perhaps use some other sound generating function. We would love to try this!

Regarding the hardware implementation, the provided potentiometer is too hard to turn and often messes with the wiring. Instead we would love to use a better/larger potentiometer that allows us better access.

Similarly, another change we would like to do is to use a single Arduino Board and breadboard rather than our current 2 board solution. This will make the project more cohesive. Even though this seems easy enough to implement, we let our current design be as of now to simplify our approach.

Lastly, the ultrasonic distance sensor often gives outlier readings. As discussed in the highlight section, we tried our best to resolve this issue, however it still persists. We have some more ideas to remedy this. But we believe that given the scope of this project this was unnecessary. However, we would love to do this in the future.

Week 10 – Slapping Music

Concept:

For this assignment of designing an unusual musical instrument, instead of making an instrument that can be actually played by people, we decided to make something that produces music on its own. Among all the electronic components we have, we think that the servo motor will be the perfect choice to show the mechanical movement of the music. And we decide to use the ultrasonic distance sensor as the main part that produces music. While the servo motor moves, the pad attached to it will move as well, leading to the changes in the distance measured by the ultrasonic sensor. According to different distances, the speaker plays sounds of different frequencies.

IMG_4401

Highlight of the code

For coding this self-playing musical instrument, we used the functions like map() that match the distance to the frequencies. We used the distance sensor code from the documentation example. While manipulating the servo motor’s position, the simple codes can produce surprising music. More over, we have the button that changes the frequency range. Whenever the button is pressed, the whole melody will be played at a higher frequency.

// assign the variables for distance and button 
#define trigPin 13
#define echoPin 12
#define buttonPin 2

// include library for Servo motor 
#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

// assign the first position
  // variable to store the servo position
int pos = 0;


void setup() {
  Serial.begin(9600);
  pinMode(trigPin, OUTPUT);  //distance
  pinMode(echoPin, INPUT);
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  
  pinMode(buttonPin, INPUT); // switch
}

int frequency; // assign the frequency variable

void loop() {
  // from distance sensor example
  long duration, distance; 
  digitalWrite(trigPin, LOW);  // Added this line
  delayMicroseconds(2);        // Added this line
  digitalWrite(trigPin, HIGH);
  //  delayMicroseconds(1000); - Removed this line
  delayMicroseconds(10);  // Added this line
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration / 2) / 29.1;


  if (distance >= 200 || distance <= 0) {
    Serial.println("Out of range");
  } else {
    Serial.print(distance);
    Serial.println(" cm");
  }


// we contrain the distance to be from 0 to 50 and map the distance values to the frequency values 
// if the button is not pushed then the melody plays in low frequencies
// if the button is pushed, then the frequency  is higher 


  if (digitalRead(buttonPin) == LOW) {
    frequency = map(constrain(distance, 0, 50), 0, 50, 100, 1000);
  } else {
    frequency = map(constrain(distance, 0, 50), 0, 50, 500, 2000);
  }


  //code for SERVO position 
  myservo.write(90);  
  delay(50);
  myservo.write(45);
  delay(50);
  myservo.write(25);
  delay(50);
  myservo.write(70);
  delay(50);
  myservo.write(100);
  delay(50);
  myservo.write(60);
  delay(50);
  // waits 50ms for the servo to reach the position
 

// play the sound from pin 6

  tone(6, frequency);


}

Reflections and Improvement

As for improvements, the appearance of the instrument could definitely be improved. For example, the entire device could be enclosed into a box that’s called music box. That will make the project more interesting and appealing. Moreover, we could include the function that allows the user to change melodies as they want. They can, for instance, manipulate the movement of the arm and the hand with a potentiometer. This gives more interactivity to the project.

Week 10 – Creative Musical Instrument

Concept:

For this week, Izah and I decided to create a musical instrument based on our favorite analog sensor: the photoresistor. To do this, we decided to utilize an interesting concept to make the instrument work: an instrument that can only be played with 2 people. The idea here was to provide a completely different experience compared to traditional musical instruments. First of all, by allowing the notes only to be played with 3 hands and second, allowing to have different notes based purely on the placement of the hand (no touch). Because no traditional instrument requires 2 people to play it, we considered that this would be a greatly innovative idea.

Demonstration

 

Code highlight:

if (switchState ==1){
    //sensor 1
    if(sensorValue1 > 500){
      currentState+=100;
    }
    else if (sensorValue1>250 && sensorValue1 < 500) {
      currentState+=10;
    }

    else if (sensorValue1 < 250){
      currentState+=1;
    }

    //sensor 2
    if(sensorValue2 > 500){
      currentState+=100;

    }
    else if (sensorValue2>250 && sensorValue2 < 500) {
      currentState+=10;

    }

    else if (sensorValue2 < 250){
      currentState+=1;
    }

    //sensor 3
    if(sensorValue3 > 500){
      currentState+=100;

    }
    else if (sensorValue3>250 && sensorValue3 < 500) {
      currentState+=10;
    }

    else if (sensorValue3 < 250){
      currentState+=1;
    }

This code provides the change of currentState. Current State can be incremented in increments of 1, 10, or 100. This ensures that the state is always controlled in a way where we can always tell exactly in what level all sensors are working on. For example, if currentState = 111, then that means that there is one HIGH, one MID and one LOW state, regardless of which is which.

Challenges:

In this project, we faced multiple challenges that slowed down and hindered our development. For starters, because of the circuit that we built, being able to sustain the structure of the instrument was a big challenge we had to face. To solve this problem, we utilized a cardboard base, supported by the same paper cups we used to cover the light for the photoresistors.

Improvements:

In this case, the improvements would be related to polishing the implementation of the photoresistor detection. One of the biggest improvements we could apply would be to place all sensors at the same angle, in such a way that all of them captured the same light level initially. By doing this, the hand movements could be more streamlined and straightforward. Because we  utilized

Another possible improvement would be to solder the photoresistors and the cables together in order to provide a more solid connection and avoid some connection problems that happen every once in a while.

Week 10 – Reading Response

In this reading, Bret Victor gives a problem that widely exists in the current visionary design for future interactions. He believes that all these visionary designs for the future have ignored the human capabilities and specifically omit millions of possible things our hands can do. The future interaction vision of the Picture Under Glass is, according to Bret, a retrograde of technology and interactions.

I think that Bret indeed makes a valid point in pointing out that future interaction designs do not make the use of the full potential capabilities of human bodies. And I can imagine that once we have the designs that enable us to interact with daily objects with our full capabilities, there will be so much more things that currently are not even imaginable becoming possible and accessible. However, as the question goes in the follow-up article, Bret does not provide a solution and he just can’t give a solution.  Even when reading this article, I actually nodded in agreement with Bret’s argument, but I couldn’t personally imagine what the ideal world for Bret would be. Will we be interacting with physical objects then? But it’s obviously not a progress in terms of interactions and technology. But again, I am in line with Bret and truly look forward to the day when our fully capabilities could be achieved in interaction designs.

This article makes me think of a recent invention I saw online. It was like a physical embodiment of Siri. This physical virtual assistant can be interacted with different modes and is capable of dealing daily affairs for its users. This virtual assistant could be activated via voice control or tapping and is powered by AI. Will this be the future given the fact that it does make our life easier?

Link to this machine introduction: https://www.youtube.com/watch?v=5fQHAZWOUuY

Reading Reflection – Week 10

A Brief Rant on the Future of Interaction Design

Watching the video of Microsoft’s Productivity Vision mainly invoked one emotion in me: apprehension. I quite agree with the author that taking “Pictures Under Glass”, magnifying them, making them 3D, and making them part of all household appliances/human interactions really is not the answer. The author comments on how our hands do so many wonderful things, like grabbing, sensing texture, and feeding us information that we take for granted. There are many more things that our brains also do, actions which would be stifled by the Vision Of The Future. For example, in the video clip, the woman arrives in an airport in Germany, taps her glasses, and immediately hears a translated version of everything around her. Firstly, phones already do this kind of work, so transferring to glasses is the sort of “meaningless step up from the status quo” the author refers to. Secondly, if someone were to go through a foreign country with all relevant information perfectly translated and projected in a hologram in front of them in real time, they would lose so much of the experience of traveling — asking what a word means, sharing a laugh over some funny mispronunciation, finding an amazing spot after getting lost, etc. It seems like these future technologies are designed to minimize mistakes, whether by finishing your sentence for you, or telling you exactly what is in your fridge, when we actually learn a lot from our mistakes. Okay, maybe it would be useful to know when something in your fridge has gone bad, but we are already able to do that with our senses of smell, touch, taste, and sight, again proving the author’s point.

Responses: A Brief Rant on the Future of Interaction Design

The paragraph that stood out to me most from this reading was:

“We’ve almost given up on the body already. We sit at a desk while working, and sit on a couch while playing, and even sit while transporting ourselves between the two. We’ve had to invent this peculiar concept of artificial “exercise” to keep our bodies from atrophying altogether… Why do you want this future? Why would this be a good thing?”

This reminded me of a reading about how the education system is not designed to encourage learning and creativity. Kids naturally learn through moving their bodies, and yet after a certain age, all knowledge is expected to be obtained by sitting at a desk, only engaging the senses of sight and hearing. The ironic thing was, I was doing this reading, learning about the failings of sitting and reading to learn by sitting and reading.

I think the author’s suggestion for truly revolutionary kinesthetic interfaces might alleviate this problem. I don’t know what form it would take, but it sounds like a good opportunity to introduce natural curiosity and bodily feedback back into our daily lives and learning processes.

Week 10 – Reading response

I found the author’s examples to be exceptionally thought-provoking. The illustration of playing the piano on a screen, like an iPad, particularly caught my attention. It led me to question the necessity of such technology. Why should we replicate complex tactile experiences on a two-dimensional surface? It highlighted the gap between the potential of human capabilities and the constraints imposed by current technological paradigms.

At its core, it seems the author is urging people to break free from traditional norms and cease restricting their thinking. There’s a profound call for a paradigm shift, a departure from the familiar and the comfortable.

The idea that technology doesn’t simply happen but is a result of choices, research, and inspired individuals resonated with me. The call to be inspired by the untapped potential of human capabilities struck a chord. It’s a call to action, urging us to reconsider the choices we make in technology development and funding. The historical reference to Alan Kay’s visionary leap serves as a powerful reminder that groundbreaking ideas often emerge from unconventional thinking.

The notion that we’ve become a generation tethered to desks, couches, and sedentary modes of transportation, necessitating artificial interventions like exercise to stave off bodily atrophy, struck a resonant chord. It not only underscores the physical implications of our evolving relationship with technology but also leads to a broader question about the increasing automation permeating every facet of our lives.

As we integrate technology into more aspects of our daily existence, there’s a palpable risk of creating a future where convenience comes at the cost of mobility and physical engagement. The critique of sitting as a prevailing posture for work, leisure, and transit raises concerns about the potential consequences of an increasingly automated lifestyle. Are we inadvertently designing a future where the need for bodily movement diminishes, contributing to a sedentary existence mediated by screens and devices?

Reading Response – Week 9

Physical Computing’s Greatest Hits (and Misses) & Making Interactive Art: Set the Stage, Then Shut Up and Listen

Both readings provided me with valuable information and insights regarding physical computing and the concept of interactive art. They share a common theme centered around originality and interpretation. The article on physical computing illustrates how even seemingly commonplace projects possess a unique touch each time different individuals recreate them. In my view, a person’s subtle influences, expressions, intentions, and interpretations of their project imbue it with a distinct originality and authenticity. Each creator infuses the project with passion, interest, and a personal story, though not always evident to the audience. This unique narrative provides value to the project unless it is an exact copy without any differences, purpose, or clear story.

Transitioning to the second article on interactive art, I concur with the author’s stance that artists should not fully disclose their interpretation and explanation of their artwork. Allowing the audience to form their own interpretations enhances the art’s impact. However, I disagree with the author’s assertion that art is solely a statement and not an expression. I firmly believe that the beauty of art lies in the story behind it, not necessarily the artist’s interpretation, but their experiences, as the author emphasizes, the art “sets the stage”; meaning that you give some insight of your experience, life, or just some context for the audience and give them a chance to interpret it on their own, since that is also one of the factors that prove the quality of an art work.

From my perspective, interactive art encompasses various fields, ranging from intricately detailed works with rich narratives to visually appealing, randomized creations. Regardless of the project type, it invariably reflects the artist’s expression. Even if the final result involves intentional or unintentional randomness, this randomness is infused with a story, emotions, and connections between perspectives, ideas, and life experiences. Even when the artist is not consciously deliberate in their production, they make decisions based on their interpretation of their own art. In some cases, the result may simply be visually appealing but still open to interpretation. Thus, I believe art can indeed make a statement, but it will always carry an expression to varying extents.

 

Week 10 – Response

The Future of Interaction Design  and Responses: A Brief Rant on the Future of Interaction Design:

The rant is about a problem in interaction designs now. They are not tangible interfaces, dynamic materials, and/or haptic. Human Capabilities were the main concern of the author. I think humans’ capabilities are daffier. As much as it was an interesting read as much as it is not inclusive. There are a lot of responsibilities and an interactive designer needs to keep in mind in terms of inclusivity. I think accessibility is a big concern. I agree that capabilities like our hands and fingers can do a lot of things and influence our futures and how they are incredible but this also made me think of those who do not have them. What should an interaction designer do? How can we help? How should we compensate?  I do not know the answer, but I hope one day I will.

I like the part when he/she started to talk about choices, and we chose what to do and how to interact. I agree and I think as interactive designers we should choose to have a responsibility to make our designs inclusive as much as we can.

I think there is a lot to be done in research regarding tangible interfaces, dynamic materials, and haptic because they are somehow inadequate. Thus, I wonder what would be a dynamic medium for keyboards.

Even though he is trying to challenge us to create designs that take advantage of our capabilities I think there should be a balance between that and the idea that capabilities might not always be equal.

 

Week 10 – Reading Reflection

Bret Victor’s perspective on the future of interaction design struck a chord with my own reflections on technological progress. Looking back at the portrayal of the future in movies, it’s clear that the evolution of technology often takes unexpected turns. The idea that inventors revolutionize existing technologies, rather than just refining them, makes sense. It’s a call to break free from envisioning the future as a mere extension of the present.

Consider the shift from fiction to reality in accessing information instantly. While the end goal remains the same, the path we took diverged significantly from those cinematic depictions. The emergence of the Internet and smartphones reshaped how we interact with information, emphasizing the need to actively shape the future rather than predict it.

I agree with Bret’s perspective, that he rehashes in his responses to “A Brief Rant on the Future of Interaction Design”, that we shouldn’t accept stagnation and minor improvements, and should still strive to achieve better design. Although touchscreens are a vision of the past come true, it would be staying in the past if we constrained the vision for future technology to what we have and know today. Touchscreens brought our vision and haptic senses together, and the user experience we can achieve through them is miles better than technology that we used to have. However, what if we were able to embed more senses into our technology? It’s hard to imagine, but that’s exactly the point. It’s easy to think about what we know already, but revolutionary ideas require exploring the unknown.