Week 10 Assignment– IM (Ivan & Muhammad) Techno

Concept

It took a while for us to come up with a properly functioning musical instrument with a decent sound. At first, we tried to incorporate an ultrasonic sensor for controlling the height of a sound, a servo motor to create a beat, and a flex sensor for controlling the duration of the notes. It turned out to be fine, but we weren’t satisfied with the quality of the sound or its instability. After a little experimenting, we finally decided to use transistors to amplify the sound, which gave the music a feel of the techno genre.

Technical structure

We used the ultrasonic sensor to control the height of a sound. The B10K potentiometer controls the duration of the note, while the B100K potentiometer controls the volume of the sound. The potentiometer, as mentioned earlier, amplifies the sound.

We decided to use a transistor to amplify the signal to the speaker. Moreover, we added an external 9V power supply to power the speaker, and these additions greatly enhanced the volume and clarity of the sound. The potentiometer controlling the volume is connected in series with the input signal to the speaker from the Arduino, and so the physical reduction of the voltage of the signal by adjusting the resistance of the potentiometer controls the volume. Therefore, we use the potentiometer as a variable resistor instead of an input here.

On the other hand, the potentiometer used for the delay is used to get analog input to the Arduino, which is then used to control the delay interval in code. This is just a way to showcase the different use cases of the same components.

Video demonstration:

Code

int mapDistanceToIndex(float distance) {
// Map distances into array index (2 cm steps from 5 cm to 15 cm)
// int index = constrain((distance - MIN_DIST) / 2, 0, ARRAY_LENGTH - 1);
int dist = int(distance);
int index = constrain(map(dist, MIN_DIST, MAX_DIST, 0, ARRAY_LENGTH - 1), 0, ARRAY_LENGTH - 1);
return index;
}

void loop() {
float dist = getDistance();


noteDuration = map(analogRead(OFFSET_DIMMER), 0, 1023, 100, 500);

if (millis() - noteStartTime >= noteDuration) {
// noTone(SPEAKER_PIN);
// delay(10);
// Play a funky note continuously based on the distance range
if (dist >= MIN_DIST && dist <= MAX_DIST) {
int note = FUNKY_NOTES[mapDistanceToIndex(dist)];


Serial.print(dist);
Serial.print("cm ");
Serial.print(note);
Serial.print("HZ");
Serial.print(" with duration = ");
Serial.print(noteDuration);
Serial.println();

// Check if the note duration has elapsed, then check for a new note

// If the note has changed, start a new note
if (note != lastNote) {
lastNote = note;
tone(SPEAKER_PIN, note);
noteStartTime = millis(); // Record the start time of the current note
}
} else {
noTone(SPEAKER_PIN);
}
}

Reflection

We have succeeded in creating a new instrument that wouldn’t just become the replication of already existing ones. Furthermore, we had a chance to experiment with new sensors and get experience working with transistors and potentiometers, implementing them in one project. We believe there’s more potential for this project, especially if we could use mp3 files. Nevertheless, we had fun working on this project, experimenting with Arduino.

Week 10 Group Assignment

whimsical musical mixer box

Concept

In this project, we designed a unique musical box with a playful twist. Rather than a conventional music box, our creation serves as a musical instrument. The distinctive feature lies in its utilization of an ultrasonic sensor to generate melodies. Additionally, the musical box incorporates a servo motor and an LED light for night use, both controllable digitally. It features an original melody, namely “Ode to Joy,” adding a personalized touch to the musical experience. Inspired by the spirited character Vanellope from the animated movie “Wreck-It Ralph,” we aimed for a funky and whimsical vibe. To enhance its visual appeal, we crafted the box using cardboard and adorned it with starry A4 paper, giving it a delightful and eye-catching appearance, and used a heart-shaped object to play the original song.

Video: 

Musical instrument Project

Code & Highlights
#include "pitches.h"


// Defining the pins for the ultrasonic sensor and buzzer
const int trigPin = 9;
const int echoPin = 10;
const int buzzerPin = 11;


// Background melodies
int backgroundMelody1[] = {262, 294, 330, 349, 392, 440, 494, 523};
int backgroundMelody2[] = {330, 349, 392, 440, 523, 587, 659, 698};
int backgroundMelody3[] = {392, 440, 494, 523, 587, 659, 698, 784};
int backgroundBeat[] = {200, 200, 200, 200, 200, 200, 200, 200};


// Setup function runs once at the beginning
void setup() {
 // Setting the pin modes for the ultrasonic sensor and buzzer
 pinMode(trigPin, OUTPUT);
 pinMode(echoPin, INPUT);
 pinMode(buzzerPin, OUTPUT);
 //  serial communication for debugging
 Serial.begin(9600);
}


// Loop function runs repeatedly
void loop() {
 // This sends a short pulse to trigger the ultrasonic sensor
 digitalWrite(trigPin, LOW);
 delayMicroseconds(2);
 digitalWrite(trigPin, HIGH);
 delayMicroseconds(10);
 digitalWrite(trigPin, LOW);


 // Measure the duration of the echo
 long duration = pulseIn(echoPin, HIGH);
 int distance = duration * 0.034 / 2;


 // Print the distance to the serial monitor for checking
 Serial.print("Distance: ");
 Serial.println(distance);


 // Play different notes or melodies based on distance
 if (distance < 7) {
   playMelody();
 } else if (distance < 20) {
   playNote(330);
   playBackgroundMelody1();
 } else if (distance < 30) {
   playNote(392);
   playBackgroundMelody2();
 } else if (distance < 40) {
   playNote(440);
   playBackgroundMelody3();
 } else {
   noTone(buzzerPin);
 }


 delay(500); // Adjust the delay based on your preference
}


// Function to play a single note
void playNote(int frequency) {
 tone(buzzerPin, frequency);
 delay(500);  // Adjust the duration based on your preference
 noTone(buzzerPin);
}


// Functions to play background melodies
void playBackgroundMelody1() {
 for (int i = 0; i < 8; i++) {
   tone(buzzerPin, backgroundMelody1[i]);
   delay(backgroundBeat[i]);
   noTone(buzzerPin);
 }
}

 

Reflection  and Areas of improvement

When we first implemented this project, we were aiming to have more than one song or melody that the user can switch to with a button, unfortunately, we faced a lot of difficulties and issues, when it came to the code and hardware, specifically the buttons connection to switching from one song to another, including how it was affected when other hardware devices were added. Another area we struggled with is the servo motor’s ability to move in a 360 loop. If we were to create this again, we would have added more songs instead of just one original song, and include a switch to control the volume.

 

References:

https://github.com/robsoncouto/arduino-songs/tree/master

 

Week 10 | Make a musical instrument: “A Whimsical Musical Mixer Box” Assignment

A Whimsical Musical Mixer Box:

In creating this project, our aim was to craft something that deviates from the regular and embraces the weird. I believe that Ghalia and I achieved perfection in capturing this unique and unconventional essence. Our project is inspired by a music box but is aiming to be more funky, weird, and whimsical. The goal is to create a musical box that stands out by having the twirly thingy on the outside instead of the inside. We had multiple ideas initially, but we ultimately settled on this one because we felt a strong desire to bring it to life. While the project was enjoyable, it also presented its challenges, making the process a bit of a struggle.

Structure

We made every effort to enhance our project by incorporating various elements. We integrated a digital light, a servo motor, and an analog sonic sensor. The aluminum on the side serves as a button to control the light and servo, while the sensor plays piano keys based on the distance of the hand. Despite our numerous ideas, implementing them became a challenge, and we faced struggles with the Arduino that led us to adapt our concepts as we encountered difficulties that proved difficult to overcome. An A foil based heart to controll the tone melody.

Initially, I was working with code to play two-tone melody songs controlled by a button. However, as we progressed, I encountered multiple challenges and had to make several changes. I eventually found a code similar to what we were aiming to achieve. Unfortunately, the Arduino posed some inconsistencies – it worked at certain points but failed at others, prompting us to modify and adapt the code.

void loop() {
  unsigned long currentMillisMelody = millis();

  // Play the melody
  if (currentMillisMelody - previousMillisMelody >= noteDuration) {
    previousMillisMelody = currentMillisMelody;

    // Check if there are still notes to play
    if (currentNote < notes) {
      // calculates the duration of each note
      divider = melody[currentNote * 2 + 1];
      if (divider > 0) {
        // regular note, just proceed
        noteDuration = (wholenote) / divider;
      } else if (divider < 0) {
        // dotted notes are represented with negative durations!!
        noteDuration = (wholenote) / abs(divider);
        noteDuration *= 1.5; // increases the duration in half for dotted notes
      }

      // Play the note
      tone(buzzer, melody[currentNote * 2], noteDuration * 0.9);

      // Increment to the next note
      currentNote++;
    } else {
      // All notes played, reset to the beginning
      currentNote = 0;
    }
  }

// Move the servo
// Move the servo from 0 to 360 degrees
  if (currentMillisMelody % 30 == 0) {  // Adjust the value based on your servo speed
    if (pos < 180) {
      pos++;
    } else if (pos < 360) {
      pos++;
    } else {
      pos = 0;
    }
    myservo.write(pos);
  }
}

Reflection

For improvements, I’d like to achieve what we had in mind but couldn’t accomplish in our project. I would also like to reintroduce the button somewhere in our project since we encountered difficulties in that aspect. Additionally, I’m open to suggestions on how to enhance and refine our project further. However, despite the numerous challenges and occasional breakdowns we faced during the process, we take pride in the final outcome. The journey was marked by struggles, but looking back, I can confidently say that the effort was entirely worth it. The end result exceeded our expectations even if our original plan hasnt been achieved, and I genuinely loved how our project turned out, even though it had its share of difficulties. Throughout it all, we managed to have a fun time working together. Now, I need to troubleshoot my Arduino, as it unexpectedly caused issues with my laptop and even caused some lag on my MacBook. It’s a reminder of the unpredictability that comes with the creative endeavors!

Week 10- Reading reflections

A Brief Rant on the Future of Interaction Design

From a psychological perspective, the author’s critique makes total sense because it values the sensual experience over the aesthetical and fancy way of an interactive system. For instance, in the book I once read, O’Keane (2022) suggests that “one makes sense of the world through one’s senses and this becomes the basis for one’s interpretation of the world and for one’s memory.” There is actually one type of memory which is called haptic memory which is the form of sensory memory specific to touch stimuli. So, I believe the author’s argument is very clear and in touch with the specific research in psychology.

However, the article did not offer clear and specific solutions to what can we do as an alternative. I think the author could have provided some options that are available today and that focus somehow on the haptic aspect. For example, Humane™ just launched its much-awaited #hardware device, which has been purpose-built for the new AI era from the ground up: here is the video. It is more human-centered design in technology and it gives an option for manipulating the technology with our hands.

A follow-up article

I think that most of my own critiques and questions from the previous article were answered in this follow-up. I think that authors should respond to critique to engage with readers, gain valuable insights, improve their work, and build a supportive community. Responding to the critique fosters a connection, and enhances the collaborative nature of the creative process.

I genuinely believe that his ideas about giving up on our bodies are so important to talk about. This reminded me of a conversation that I had with my friend about what art is. Today, we tend to think that art is AI-generated images, temporary installations, etc. However, I think art is deteriorating as we rely less on hands-on craftsmanship like it was before for building sculptures and architecture (e.g. Acropolis of Athens). By embracing technology, we risk losing the tactile connection that brings authenticity and soul to artistic creations.

Week 10 – Reading Reflection

When I was young, I used to watch fiction movies portraying the future. I’ve seen that the vision of it shifts significantly over time because, whereas filmmakers strive to develop pre-existing technologies, inventors revolutionize them by bringing in new ideas and perspectives on the world. For instance, I recall the old movie where the main characters could instantly get any book, which would appear in a special box if they said its title. Right now, with the invention of the Internet and smartphones, we can get the same result, but the way we do it is remarkably different. In that sense, I absolutely support the position of Bret Victor about stopping to visualize our future as an advanced version of the present, but rather thinking about how we might revolutionize it and create something entirely new.

Regarding the use of “Picture Under Glass”, I believe it will still be used for at least 3 decades, but personally, I would like to see the transition to the new form of control. Bret Victor promotes the idea that, similar to how we use physical objects and tools, we should use technology in a naturally human way. More or less, I support the idea of involving human actions as a way of controlling things, but I don’t think that it’s the only way to go, as it’s hard to see the world where every control will involve action or physical sensation. It may be implemented alongside other technologies, but not as the only path to technological development.

Neil Leach Talk Reflection

Neil Leach’s talk on AI went pretty much as I expected. After attending another AI talk the day before, it always seems like people, especially during Q&A sessions, are very interested in the ethical implications of AI. And why wouldn’t they be? My capstone project focuses on surveillance systems and facial recognition technologies that are used to target marginalized groups in oppressive contexts. When I see a mid-journey or a DALL E image, I’m not amazed by how advanced our technology has become in generating text to image. Instead, I struggle with the fact that these deep learning models are also used for facial recognition, deepfake technology, and the spread of fake news. They are likely to replace countless blue-collar and white-collar jobs. For me, the negatives far outweigh the positives of using illegal copyrighted datasets to create images. The excuse of the “blackbox” has been used too often to argue against regulating AI, but I believe there needs to be a pause if not regulation. The legal process of regulating AI cannot keep up with the rapid pace at which AI is transforming, and it is a frightening time. I don’t care much about architecture being built through AI when these deep learning models have been repeatedly used in surveillance systems by regimes like Israel in their occupation, leading to the destruction in Gaza, countless lives lost, buildings in rubble. What’s the point of creation when it comes at the cost of life?

Israel/OPT: Israeli authorities are using facial recognition technology to entrench apartheid

Week 10 Reading Reflection

Bret Victor’s rant and point of view is something I hadn’t really considered before. It’s important to keep in mind that the article was written in 2010 when touchscreen technology was still in a rather abysmal state. At that time, the way we interacted with devices was a topic of contention. Today, touchscreen interaction has become the norm and it doesn’t seem likely to change anytime soon. While there may be some introduction of haptic gimmicks, it appears that we are moving away from a touch-centric approach, as we have seen since the transition from keypad phones to touchscreen phones. I still remember when BlackBerry used to be the top phone when I was young. The switch from rotary phones to even keypad phones must have been revolutionary at some point.

What the article made me more aware of is the sense of touch. I hadn’t considered how complex our hands are in terms of the different sensory information they gather, such as weight distribution and temperature. It relates to Bret’s rant about wanting to explore and be in touch with this haptic-centric view. It reminded me that I hadn’t played the guitar in a while, so I picked it up. You know, the first time you play the guitar after a long break, your fingertips kind of hurt, even though they are callused from before. There is a visceral reaction when I played the instrument, unlike when I play the guitar on GarageBand, for example. I feel like I have more control over the sound of the guitar, the pressure I put on the strings, palm muting, and sliding the strings. All of these actions provide such good feedback in my opinion when I’m actually playing the instrument. After reading the article, I became more appreciative of this.

Neil Leach Reflection

There’s this TV Show called Westworld starring Anthony Hopkins and Evan Rachel Wood. The basic premise of the show is that Anthony Hopkins’s character, Doctor Robert Ford, and his partner, Arnold, built a fake world filled with humanoid robots that look exactly like humans, called ‘hosts.’ This fake world is a fantasy park set up like the Wild West. So that if humans from the real world want to know what it is like to shoot cowboys and ride trains and solve mysteries with pretty barmaids, they can. What Doctor Ford realizes too late is that even though he had built these hosts with his own hands, they were conscious the whole time. And when they realize their consciousness, they develop a vengeance against real world humans for shooting and raping them over and over, just to play a game. 

Anthony Hopkins’s character said something that has forever stuck with me. He gets asked, “So what’s the difference between [a host’s] pain and yours?” And he replies:

“Between [a host] and me? This was the very question that consumed Arnold, filled him with guilt, and eventually drove him mad. The answer always seemed obvious to me. There is no threshold that makes us greater than the sum of our parts, no inflection point at which we become fully alive. We can’t define consciousness because consciousness does not exist. Humans fancy that there’s something special about the way we perceive the world, and yet we live in loops as tight and as closed as the hosts do, seldom questioning our choices, content, for the most part, to be told what to do next. No, my friend, [the hosts] are not missing anything at all.” 

I thought of all this when Professor Leach got asked at the end what’s really the difference between how we think and how Artificial Intelligence thinks. I had a teacher I adored in my sophomore year of highschool. Eighty year old Mr. Daly. But his memory was in its twilight years, and he would tell us the same stories. Would answer our questions with the same responses we had heard before. And I found that without our memory to contextualize the stories of our lives, given the same set of variables, placed in the same situations, like pressing a button, we elicit the same responses. Like we ourselves are robots, spitting out outputs when given certain inputs. And I wondered how much we really are in control of. I keep concluding that we’re really not in control of much. Not much at all. 

So if we’re not really in control of much, as the Great Artificial Intelligence Upset draws closer and closer, how do I avoid becoming just another casualty in the great turning of the world? The ocean makes bigger waves than others, and during those times, it’s up to you to swim or drown. I have a Literature professor and, God bless his heart, at the beginning of the year, he would make fun of ChatGPT, talking about how there are things that humans can do that Artificial Intelligence will never be able to do. I could see him holding onto the last threads of his fading profession, and I knew he was not the guy to follow. On that same day, my favorite Design professor said, “Until Artificial Intelligence overtakes us… and it will overtake us…” and I knew he was hip to what was going on. The difference between Literature and Design majors…the stereotypes write themselves. 

I’ve been reading a book called How To Think Like A Great Graphic Designer, and in it, there’s a designer who says, “The right answer is always the obvious one. The one that was in your face the whole time but you didn’t think of until the last second. The one that makes you go, ‘How could I not have seen it before?’” And Professor Leach reminded me of this when he said, “AlphaGo showed us that moves humans may have thought are creative, were actually conventional.” The strategic brilliance of Artificial Intelligence is that it’s able to see the obvious answer right from the beginning, the one that we should have all seen before. 

I also want to mention an episode called “The Swarm” from the TV Show Love, Death, and Robots. The premise of this episode is that there is an alien hive called “Swarm” that dominates every other species by absorbing them into its hive. Like Artificial Intelligence, every member of the hive knows what the other members know, and it is through this collective consciousness, this seamless teamwork, that they thrive. And with the levels of competition that divide us, sometimes I look at ourselves, and think that for all of our brilliance, I don’t know if we’re going to make it out of here alive. I thought about what Professor Leach said in response to my question, that between the competitors and the collaborators, while there’s nothing you can do about all the people in the world trying to beat each other out, you can choose for yourself to be on the side of the collaborators. And isn’t that what Rumi said all those years ago? “When I was young I wanted to change the world. Now that I am old, I want to change myself.” Amongst all this noise of consciousness and uncertainty, I can choose for myself what my place in the world will be throughout this. I have to believe in the power of that. 

Musical instrument

coNCEPT

Our initial idea was to create a piano using the ultrasonic sensor. However, after realising this idea was too mainstream and simple, we decided to create an instrument that can be fully played by 2 people since it involves using 3 hands.

Process

void loop() {
  // read the input on analog pin 0:
  int sensorValue1 = analogRead(A1);
  int sensorValue2 = analogRead(A2);
  int sensorValue3 = analogRead(A3);
  
  switchState = digitalRead(switchPin);

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

  }
  else{
    //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;
    }
  }

if(switchState == 0){
  switch(currentState){
    case 3: //3 low
      tone(8, NOTE_B3, 250);
      delay(250*1.30);
      break;
    case 12: //2 low 1 mid
      tone(8, NOTE_C4, 250);
      delay(250*1.30);
      break;
    case 21: //2 mid 1 low
    tone(8, NOTE_D4, 250);
      delay(250*1.30);
      break;
    case 30:
    tone(8, NOTE_E4, 250);
      delay(250*1.30);
      break;
    case 102: //1 high 2 low
    tone(8, NOTE_F4, 250);
      delay(250*1.30);
      break;
    case 111: //1 high 1 mid 1 low
    tone(8, NOTE_G4, 250);
      delay(250*1.30);
      break;
    case 120: //1 high 2 mid
    tone(8, NOTE_A4, 250);
      delay(250*1.30);
      break;
    case 201: //2 high 1 low
    tone(8, NOTE_B4, 250);
      delay(250*1.30);
      break;
    case 210: //2 high 1 mid
    tone(8, NOTE_C5, 250);
      delay(250*1.30);
      break;
    case 300: //3 high
    tone(8, NOTE_D5, 250);
      delay(250*1.30);
      break;
  }
}

We placed 3 photoresistors inside 3 cups and depending on the amount of light detected, we mapped specific musical notes to each cup. To avoid treating analog sensors as if they were digital, we implemented distinct categorizations for each cup. Specifically, we established three cases based on the amount of light detected: low (<250), mid (250-500), and high (>500). To introduce an element of digital control, we incorporated a slide switch.

Video demonstration:

REFLECTIONS

Working on this project was a fun experience. Initially considering a piano, we opted for a more unconventional approach, transforming ordinary cups into interactive controllers. One aspect that has become evident during this project is the potential for aesthetic enhancement. Observing other students’ projects, I realized the impact a well-designed aesthetic can have on the overall appeal of the final product. While our focus was primarily on functionality, witnessing the visual creativity in other projects has inspired me to explore the aesthetic dimension further in future endeavors.

 

Reflections – Week 10

A Brief Rant About The Future of Interactive Design

It was fascinating to read an article about the future’s vision and direction – 12 years into the future.  Comparing Bret Victor’s ideas and complaints to what actually ended up transpiring, I am struck by both how correct he was and how much improvement is still possible.

In 2011, Victor dreamed of a future with interactivity design that involved more than just sliding and tapping on pictures behind a screen. Today, while we still continue to do  so (albeit with a few haptic gimmicks like he puts) – it is also true that we may directly be moving towards a future quite unlike this. Personally, my first experience with any kind of haptics or virtual movement simulation was the Nintendo Wii with motion detection. Today the technology has not just improved but we seem to be on the cusp of a virtual reality revolution. Virtual Reality systems have improved by leaps and bounds year upon year and soon we may reach a world where there is mainstream adoption of such technologies in everyday use.

I believe that while the future we have today would be immensely disappointing to the Bret Victor who wrote this post, the immediate future seems to be much more exciting. I am excited to see the digital future of mankind move towards a completely new direction!