Reading Reflections – Week 12

Design Meets Disability

Reading this text about design meets disability has been eye-opening for me as a designer. It reminds me of the struggle to find the right balance between making products functional, looking good, and fitting in socially.

One thing that stood out to me was the idea of the “flying submarine,” which means adding too many features to a product. I’ve faced this problem before, where trying to include everything makes designs too complicated and less effective. It’s interesting to see how James Leckey’s approach of focusing on specific designs instead of trying to please everyone addresses this problem. I wonder how this idea could apply to other kinds of designs, not just those for disabilities.

I also found the examples of the iPod shuffle and the wall-mounted CD player interesting. They show how simplicity can make products easier to use, even if it means losing some features. I’ve struggled with this balance in my own work—how do we decide which features are really necessary and which ones we can leave out?

As a designer, this text reminds me to think more about how my designs can meet everyone’s needs while still being creative. How do we make sure our designs work for everyone? It’s a challenge I’m excited to take on, and I look forward to learning more about inclusive design.

Musical Instrument – Week 11 Assignment

Group members: Muhammed Hazza, Iqra Bano

Concept

For our assignment, we’ve decided to create a musical instrument, and we settled on making a piano with four keys. Each key, when pressed, will produce a different tone. Our circuit is straightforward, utilizing four push buttons and a buzzer. However, we’ve added an extra component: a potentiometer. This potentiometer allows us to change the frequency of the tones produced by the buzzer. By turning the potentiometer, we can adjust the pitch of the notes, adding more flexibility and range to our piano.

Video Demonstration

Materials we used

  1. Arduino Uno board
  2. Breadboard
  3. 330-ohm resistor
  4.  4x Tactile push-button switch
  5. Potentiometer
  6. Jumper wires
  7. Piezo buzzer

TinkerCad Diagram

Code

#include <Tone.h>

// Define the notes with more distinguishable frequencies.
#define NOTE_C 262 // Middle C (C4)
#define NOTE_G 392 // G above Middle C (G4)
#define NOTE_C_HIGH 523 // One octave above Middle C (C5)
#define NOTE_G_HIGH 784 // G above C5 (G5)

#define ACTIVATED LOW

const int PIEZO = 11;
const int LED = 13;

const int BUTTON_C = 10;  // Will play Middle C
const int BUTTON_D = 9;   // Will play G (above Middle C)
const int BUTTON_E = 8;   // Will play High C
const int BUTTON_F = 7;   // Will play High G

const int POTENTIOMETER = A0; // Analog input pin connected to the potentiometer

Tone toneGenerator;

void setup() {
  pinMode(LED, OUTPUT);
  
  pinMode(BUTTON_C, INPUT_PULLUP);
  pinMode(BUTTON_D, INPUT_PULLUP);
  pinMode(BUTTON_E, INPUT_PULLUP);
  pinMode(BUTTON_F, INPUT_PULLUP);

  toneGenerator.begin(PIEZO);
  digitalWrite(LED, LOW);
}

void loop() {
  int potValue = analogRead(POTENTIOMETER); // Read the potentiometer value
  int frequencyAdjustment = map(potValue, 0, 1023, 0, 255); // Map to a quarter of the full range for adjustment
  
  if (digitalRead(BUTTON_C) == ACTIVATED) {
    toneGenerator.play(NOTE_C + frequencyAdjustment); // Adjust Middle C frequency
    digitalWrite(LED, HIGH);
  } else if (digitalRead(BUTTON_D) == ACTIVATED) {
    toneGenerator.play(NOTE_G + frequencyAdjustment); // Adjust G frequency
    digitalWrite(LED, HIGH);
  } else if (digitalRead(BUTTON_E) == ACTIVATED) {
    toneGenerator.play(NOTE_C_HIGH + frequencyAdjustment); // Adjust High C frequency
    digitalWrite(LED, HIGH);
  } else if (digitalRead(BUTTON_F) == ACTIVATED) {
    toneGenerator.play(NOTE_G_HIGH + frequencyAdjustment); // Adjust High G frequency
    digitalWrite(LED, HIGH);
  } else {
    toneGenerator.stop();
    digitalWrite(LED, LOW);
  }
}

Functionality

  • Upon pressing a button, the Arduino reads which button is pressed and plays a specific tone. The potentiometer’s position adjusts the base frequency of this tone, making the sound higher or lower based on its rotation.
  • The piano uses the Arduino’s built-in “tone” library to handle tone generation, which simplifies the creation of audible frequencies through digital pins.

Future Improvements

For future improvements we would like to:

  • Enhance the clarity and volume of the piano’s notes.
  • Add more keys and different types of tones to the piano.
  • Integrate LEDs to make it look more attractive and visually appealing.

W12- Final Project Idea

As I was brainstorming potential ideas for my final project, I realized that a key concept I want to focus on is the essence of being human, specifically touching upon the elements that make us human such as emotion, heartbeat, facial expressions, etc. The reason why I want to focus on this specific topic is because I am intrigued by the ways in which humans and computers are able to interact with one another, and what the implications of such an interaction might be. Although this project will not lead to wide implications for the world of human-computer interaction, I believe that simply understanding how such an interaction can work is in of itself important. Therefore, it is through actually engaging with such interactions that we can understand the different ways in which the users and computers can interact to create a system/ illustration that exhibits data of some kind. 

After brainstorming, I tried to find inspiration by looking up youtube videos related to the concept of humanness. A common project I noticed was the interactive glove, in which users are able to control certain projects with the movement of their hands. This, in my eyes, is a good utilization of humanness. It embraces a critical part of human nature and combines it with computer interaction. A good example that I found of this can be seen below: 

However, I know I do not want to do a project that has to do with building an interactive glove. Instead, I want to create a project in which the human heart beat is detected in order to create fast or slow paced interactive art. I want to create an even more comprehensive user-experience, which is why I want to add the option of changing the color of the interactive art displayed after detecting the user’s heartbeat. Although I do not know the intricate details of the project yet, I do know that committing to such a project will allow me to explore my interest in human computer interaction and utilize it to create personal interactive art for users.

Last reading reflection

Design Meets Disability:

https://intro.nyuadim.com/wp-content/uploads/2020/08/Design_meets_disability.pdf

In the reflection article on Graham Pullin’s book “Design Meets Disability,” important themes are discussed that relate design principles to real-world requirements and societal views on disability. Pullin is a proponent of minimalist design, contending that functionality demands it, particularly when creating for people with disabilities. I identify with this point of view since it goes against the grain of conventional thinking, which prioritizes aesthetics over usefulness. The user experience can be greatly improved by both useful and aesthetically pleasing aspects, therefore I find myself thinking about how to strike a balance between both.

An important ethical problem arises from Pullin’s claim that “disability inspires design” and that such designs should strive to make the user blend into their environment. It implies a hidden desire to hide a disability, which could reinforce the stigma instead than celebrating variety. Pullin uses eyewear as an example of how design and function can be successfully combined, turning glasses from basic medical devices into fashionable accessories that are generally accepted in society. This change demonstrates how design has the ability to affect society norms and perceptions.

But this begs the question of whether the goal of design ought to be to celebrate individuality and promote empowerment, or to assist people with disabilities in “blending in.” It may be restrictive to assume that excellent design equals to being discrete, as design has the power to question and transform social norms.

Furthermore, while its importance, Pullin’s emphasis on usefulness and simplicity ignores the nuanced interactions that exist between a person’s identity and their tools or assistance. This error makes me wonder about the possibilities of design as a means of expressing uniqueness as well as serving as a functional solution. Could designs celebrate and reflect the variety of user experiences in addition to meeting practical needs?

The book “Design Meets Disability” definitely made me rethink design concepts by highlighting how important it is to take an inclusive approach that prioritizes both beauty and practicality. It also made people think more deeply about how designs affect how society perceives identity and disability. After reading this, I’m left feeling that there are a lot of opportunities for careful design to make the world more inclusive.

Week 11 | Creative Reading response

“A Brief Rant on the Future of Interaction Design” by Bret Victor is a rant about the lack of innovative vision for future technologies. Seeing the video at the beginning, I first thought that this seems like a great future. However, as I read the article, I increasingly came to the realization that the future shown in the video could be much better and visionary . Victor’s criticism of the use of only fingers got me thinking that if we could do so many things with just a finger, how many possibilities could be unlocked if we used our entire hand? He talks about this in detail and heavily criticized visions of the future that focus on just screens. This made me realize that I should look to make something that involves interaction from the entire hand and involves as much touch interaction as possible using tactile interfaces such as buttons.

Although Victor does not offer a solution to his rant, his way of thinking inspires me.  Although he does not present a solution, he states the problem very clearly and I agree with him. I would love to work on something that uses tactile input from more than just a fingertip for my future projects and for my Final project for this course too .

Week 11: Group Musical Instrument

Group members: Muhammed Hazza, Iqra Bano

Concept

For our assignment, we decided to create a musical instrument, and we settled on making a piano with four keys. Each key, when pressed, will produce a different tone. Our circuit is straightforward, utilizing four push buttons and a buzzer. However, we’ve added an extra component: a potentiometer. This potentiometer allows us to change the frequency of the tones produced by the buzzer. By turning the potentiometer, we can adjust the pitch of the notes, adding more flexibility and range to our piano.

Video Demonstration

Materials we used

– Arduino Uno board

– Breadboard

– 330-ohm resistor

– 4x Tactile push-button switch
– Potentiometer

– Jumper wires
– Piezo buzzer

TinkerCad Diagram

 

 

 

 

Functionality

Upon pressing a button, the Arduino reads which button is pressed and plays a specific tone. The potentiometer’s position adjusts the base frequency of this tone, making the sound higher or lower based on its rotation.

The piano uses the Arduino’s built-in “tone” library to handle tone generation, which simplifies the creation of audible frequencies through digital pins

 

 

 

 

Code

#include <Tone.h>

// Define the notes with more distinguishable frequencies.
#define NOTE_C 262 // Middle C (C4)
#define NOTE_G 392 // G above Middle C (G4)
#define NOTE_C_HIGH 523 // One octave above Middle C (C5)
#define NOTE_G_HIGH 784 // G above C5 (G5)

#define ACTIVATED LOW

const int PIEZO = 11;
const int LED = 13;

const int BUTTON_C = 10;  // Will play Middle C
const int BUTTON_D = 9;   // Will play G (above Middle C)
const int BUTTON_E = 8;   // Will play High C
const int BUTTON_F = 7;   // Will play High G

const int POTENTIOMETER = A0; // Analog input pin connected to the potentiometer

Tone toneGenerator;

void setup() {
  pinMode(LED, OUTPUT);
  
  pinMode(BUTTON_C, INPUT_PULLUP);
  pinMode(BUTTON_D, INPUT_PULLUP);
  pinMode(BUTTON_E, INPUT_PULLUP);
  pinMode(BUTTON_F, INPUT_PULLUP);

  toneGenerator.begin(PIEZO);
  digitalWrite(LED, LOW);
}

void loop() {
  int potValue = analogRead(POTENTIOMETER); // Read the potentiometer value
  int frequencyAdjustment = map(potValue, 0, 1023, 0, 255); // Map to a quarter of the full range for adjustment
  
  if (digitalRead(BUTTON_C) == ACTIVATED) {
    toneGenerator.play(NOTE_C + frequencyAdjustment); // Adjust Middle C frequency
    digitalWrite(LED, HIGH);
  } else if (digitalRead(BUTTON_D) == ACTIVATED) {
    toneGenerator.play(NOTE_G + frequencyAdjustment); // Adjust G frequency
    digitalWrite(LED, HIGH);
  } else if (digitalRead(BUTTON_E) == ACTIVATED) {
    toneGenerator.play(NOTE_C_HIGH + frequencyAdjustment); // Adjust High C frequency
    digitalWrite(LED, HIGH);
  } else if (digitalRead(BUTTON_F) == ACTIVATED) {
    toneGenerator.play(NOTE_G_HIGH + frequencyAdjustment); // Adjust High G frequency
    digitalWrite(LED, HIGH);
  } else {
    toneGenerator.stop();
    digitalWrite(LED, LOW);
  }
}

Future Improvements

For future improvements we would like to:

Enhance the clarity and volume of the piano’s notes.
Add more keys and different types of tones to the piano.
Integrate LEDs to make it look more attractive and visually appealing.

Assignment 7: Automatic Musical Doorbell

Concept

For the 7th Assignment in our Introduction to Interactive Media course, we were assigned the task of creating a musical instrument that incorporates at least one digital and one analog sensor. After brainstorming various ideas, we decided to design an interactive project that combines functionality with musical creativity. Our concept is an “Automatic  MusicalDoor Bell”.

Our concept envisions a scenario where, as a person approaches and comes within 20 centimeters of the distance sensor, the system is triggered to play melodious door bell music. This immediate and musical response not only alerts the presence of someone at the door but also enhances the interaction with a harmonious greeting.

Implementation

In the development of our interactive door bell project, we aimed to create a distinctive auditory experience that went beyond the typical door bell chime. To achieve this, we programmed the Piezo buzzer to emit a unique melody rather than a standard tone. This melody was carefully chosen to be pleasant and welcoming, enhancing the interactive aspect of our device.

To further enrich the sonic experience, we introduced physical elements that function as percussive instruments. Specifically, we utilized a steel bottle and a glass cup, both positioned to serve as drums. These items were chosen for their resonant qualities and the distinct sounds they produce when struck.

The action of striking these improvised drums is controlled by a servo motor, to which a drumstick is attached. As the servo motor rotates in response to the proximity detected by the distance sensor, the attached drumstick swings. It hits the steel bottle on one side and the glass cup on the other.  The combination of this sound with the melody from the buzzer results in a complex musical note that is triggered by the presence of a person within the sensor’s 20 cm range.

The entire system is designed to be responsive: as soon as the ultrasonic distance sensor detects something within its range, both the servo motor and the buzzer are activated, collaboratively producing a musical output. This not only signals the presence of a visitor but does so in an unexpectedly musical way, turning a simple functional alert into an engaging and enjoyable experience.

Demo Video

A demo video, in detail, can be seen here:

Pictures of Circuit

Difficulties and Limitations

One of the significant challenges we faced during the implementation of our project was selecting the appropriate materials for the drum components. The process of determining the ideal materials involved extensive trial and error. We experimented with various types of cups and materials for the drumstick to achieve the desired sound quality and durability.

Looking ahead, for future iterations of the project, we aim to explore a broader range of frequencies for the buzzer, allowing for more diverse musical expressions. Additionally, adjusting the angles and speeds of the servo motor holds potential for creating a more dynamic and visually appealing interaction. These enhancements will not only improve the functionality of our device but also enrich the user experience, making each interaction with the door bell a unique and enjoyable moment.

Code

#include <Servo.h>

// Constants for the pins
const int buzzerPin = 4;
const int servoPin = A5;
const int triggerPin = 6;
const int echoPin = 5;

// Create a Servo object
Servo myServo;

// Variables for the distance measurement
long duration;
int distance;

void setup() {
  // Set the buzzer pin as output
  pinMode(buzzerPin, OUTPUT);
  // Initialize the servo
  myServo.attach(servoPin);
  // Set the ultrasonic sensor pins
  pinMode(triggerPin, OUTPUT);
  pinMode(echoPin, INPUT);
  // Begin serial communication (for debugging purposes)
  Serial.begin(9600);
}

void loop() {
  // Measure the distance from the ultrasonic sensor
  digitalWrite(triggerPin, LOW);
  delayMicroseconds(2);
  digitalWrite(triggerPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(triggerPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = duration * 0.034 / 2; 

  // Check if something is within the desired range
  if (distance < 20) { 
    // Rotate servo to 180 degrees
    myServo.write(60);
    // delay(10);
    // myServo.write(50);
    delay(100); 
    // Rotate servo back to 0 degrees
    myServo.write(0);
    delay(250); 

    // Play a melody
    playMelody();
  } else {
    // Keep the servo at 0 degrees when not activated
    myServo.write(0);
    // No sound
    noTone(buzzerPin);
  }


  // Serial.print("Distance: ");
  // Serial.println(distance);
  
  delay(100); 
}

void playMelody() {
  // Note frequencies, e.g., C4, D4, E4, F4
  int melody[] = {262, 294, 330, 349};
  int noteDurations[] = {200, 200, 200, 200};  // duration of each note in milliseconds

  for (int thisNote = 0; thisNote < 4; thisNote++) {
    // To calculate the note duration, take one second divided by the note type.
    //e.g., quarter note = 1000 / 4, eighth note = 1000/8, etc.
    int noteDuration = noteDurations[thisNote];
    tone(buzzerPin, melody[thisNote], noteDuration);

    // To distinguish the notes, set a minimum time between them.
    // The note's duration + 30% seems to work well:
    int pauseBetweenNotes = noteDuration * 1.30;
    delay(pauseBetweenNotes);

    // Stop the tone playing:
    noTone(buzzerPin);
  }
}

 

 

Week 11: Response on A Brief Rant on the Future of the Interaction Design

A brief rant on the future of interaction design

I thoroughly enjoyed reading ‘A Brief Rant on the Future of the Interaction Design’ by Bret. His article grabbed my attention from beginning to end with his discussion on the future of interactive design. It was fascinating to see his depiction of how everything might soon operate through mere hand movements. While this vision has its flaws, it opened up exciting possibilities for what the future could look like.

Bret makes an interesting transition by focusing on how current interactive designs primarily utilize hands for touch interactions – which he is also referring as ‘Pictures under Glass’. And I share his point of view too, **** for a decade of touch screen interactions it does seems limited when considering the full tactile and motor capabilities of hands, which are not fully exploited by today’s technologies. I was also intrigued by why Bret chose to critique the specific interactive design video. As we advance in the field of interactive design, it seems paradoxical that the way we interact with technology isn’t evolving in tandem.

Bret advocates for more varied hand interactions, which is a valid point given the context of the article’s 2011 publication. Back then, the predominant interaction models featured simple touch and slide gestures. Since then, technology has evolved. Devices like the Apple Vision Pro now incorporate gestures like pinching, using both hands to grasp and manipulate objects—yet, our hands’ full range of abilities remains largely underutilized in technological interfaces.

And this left me thinking some pressing questions: Will we see improvements that add greater depth to how we interact with technology, or are there inherent limitations in the systems we use that prevent them from fully embracing all possible interactions? or will we see innovations that allow for a richer, more intuitive user experience?

Responses: A Brief Rant on the Future of Interaction Design

I enjoyed reading Bret’s responses to the comments on his article, particularly two points that stood out to me.

Why is he forcing too much to add the other ‘hand involved’ interactions? — that was one of my questions when I was reading Bret’s article. I initially struggled to understand why adding other interactions was so important. Some suggested using voice commands, but Bret put it well by saying — that imagining, building, or designing things is something that our hands do better, because those voice instructions ‘just exist in space, and we manipulate space with our hands’. And this does make me think about how humans psychologically respond to the stimulus that require them to adjust, rebuild. And what is even the cognitive debate on ‘how human body are designed to interact?’, says that manual interaction is often preferred for creative tasks because it engages motor skills, spatial reasoning, and visual processing, enabling direct and nuanced control over the creative process. This mode provides immediate tactile and visual feedback, which is essential for fine-tuning and detailed work, making it more effective for tasks that require precision and sensory integration, such as painting or building models. So Bret’s point really resonates with me when he says ‘You come to understand the system by pointing to things, adjusting things, moving yourself around the space of possibilities. I don’t know how to point at something with my voice. I don’t know how to skim across multiple dimensions with my voice.’ But now here is another thing, ‘What about Vision?’, I thought maybe that debate was missing from the responses, I was curious to know what about, human interaction with other the technology that uses our ‘Eyes’ such as in this age our ‘Vision Pro’, it was later that I realized that this question was also well answer by his another response to a comment, where he quoted a neuroscientist; who stated that; If we don’t use our fingers to explore the world, especially during childhood, we lose a significant part of our brain’s potential, hindering our overall development which is going to be similar to having blindness.

Now it kind of makes me conclude that the push for more sophisticated hand interactions in technology stems from the need to preserve natural human capabilities in an increasingly advanced world. If we replace our everyday interactions with less interactive technologies, we risk losing a crucial part of ourselves in the process. While it might seem tangential, this issue is similar to how our reliance on small devices has reduced face-to-face social interactions. Although technology offers benefits, it also challenges us psychologically and biologically as we adapt, often leading to issues that affect both individuals and society as a whole.

Luke and Yaakulya – Week 11 Assignment – Turntable

Week 11 – Turntable

Concept & Inspiration:

Approaching this assignment, we wanted to create a turntable that can let user become a DJ controlling two songs. This DJ takes the party people from West to East, blending music from a Western country across the globe to an Eastern country. We have the supposedly the most popular song on the planet at the moment (no, it’s not Baby Shark), the pop song with the most views on YouTube, the song that caused a whirlwind, Despacito by Luis Fonsi and Daddy Yankee from Puerto Rico. We also have the all-time iconic Mario Theme Song hailed from Japan composed by Koji Kondo for the video game company Nintendo. The DJ user can control these two songs by using the switch button as the digital sensor and the potentiometer as an analog sensor. As for the songs, we picked the most memorable and recognizable parts: the chorus for Despacito and the gameplay theme for Mario Theme Song.

Circuit:

Circuit connections from above Schematics diagram.

1) Potentiometer Connections: The potentiometer is crucial for song selection and control. It has three pins: two for power and one for the signal. The outer pins are connected to the 5V and GND (ground) terminals on the Arduino to provide it with power. The middle pin, which is the wiper, is connected to the analog input A0 on the Arduino. As the user turns the knob of the potentiometer, the resistance changes, and the Arduino reads this as an analog value, allowing the user to blend between the two songs.

2) Button Connections: A push button is used to start or stop the song playback. One side of the button is connected to the digital pin 2 on the Arduino. The other side is connected to the GND terminal on the breadboard. A pull-up resistor is not necessary as the Arduino’s internal pull-up resistor is used in the code to avoid floating values when the button is not pressed.

3) Speaker Connections: The speaker, which outputs the sound, has two wires. The positive wire is connected to digital pin 8 on the Arduino. This pin is set up in the code to deliver a pulse-width modulation (PWM) signal that creates the audio tones for the songs. The negative wire from the speaker is connected directly to the GND terminal on the breadboard to complete the circuit.

4) Power Connections: The breadboard’s power rail is used to distribute the 5V and GND connections to the potentiometer and the button. Wires run from the 5V and GND pins on the Arduino to the power rail on the breadboard.

With this setup, the user interacts with the button and potentiometer to control the playback of “Despacito” and the “Mario Theme Song”. The code on the Arduino processes the input signals and triggers the speaker to play the appropriate song based on the state of the button and the value from the potentiometer.

What does the Analog and Digital Sensor do in this circuit? – Schematics:

The code and circuit are structured to respond to the interactions with the potentiometer and the push button:

1) Button Press: Initiates the playback of “Despacito” or stops the current song.

2) Potentiometer Rotation: Facilitates the blending from “Despacito” to the “Mario Theme Song.” and vice versa.

The user must press the button to start playing “Despacito.” They can then rotate the potentiometer to initiate the “Mario Theme Song” by pressing the button again. This interaction can be repeated to switch between the two songs.

Code (with comments):

The button acts as a trigger to play the music and the potentiometer act as a dial to alternate between the 2 songs. The first song is Despacito. The user have to press the button for it to play. Then they can turn the potentiometer to the other side and press the button again to play the second song, Mario Theme Song. They can repeat playing these two songs however much they want.

#include "pitches.h"
#define BUZZER_PIN 9
#define POTENTIOMETER_PIN A0
#define BUTTON_PIN 7
// Melody for the first song
int melody1[] = {
  NOTE_D4, NOTE_CS4, NOTE_B3, NOTE_FS3, NOTE_FS3, NOTE_FS3, NOTE_FS3, NOTE_FS3,
  NOTE_FS3, NOTE_B3, NOTE_B3, NOTE_B3, NOTE_A3, NOTE_B3, NOTE_G3, NOTE_G3, NOTE_G3, NOTE_G3, NOTE_G3,
  NOTE_G3, NOTE_B3, NOTE_B3, NOTE_B3, NOTE_B3, NOTE_CS4, NOTE_D4, NOTE_A3, NOTE_A3, NOTE_A3, NOTE_A3, NOTE_A3,
  NOTE_A3, NOTE_D4, NOTE_D4, NOTE_D4, NOTE_D4, NOTE_E4, NOTE_E4, NOTE_CS4
};
// Note durations for the first song
int noteDurations1[] = {
  4,4,8,8,16,16,16,16,
  16,16,16,8,16,8,16/3,16,16,16,16,
  16,16,16,16,8,16,8,16/3,16,16,16,16,
  16,16,16,16,8,16,8,16/3
};
// Melody for the second song
int melody2[] = {
  NOTE_E4, NOTE_E4, NOTE_E4, NOTE_C4, NOTE_E4, NOTE_G4, NOTE_G3, NOTE_C4, NOTE_G3, NOTE_E3, NOTE_A3, NOTE_B3, NOTE_AS3, NOTE_A3,NOTE_G3,NOTE_E4,NOTE_G4,NOTE_A4,NOTE_F4,NOTE_G4,NOTE_E4,NOTE_C4,NOTE_D4,NOTE_B3,NOTE_C4
};
// Note durations for the second song
int noteDurations2[] = {
  16,8,8,16,8,4,4,16/3,16/3,16/3,8,8,16,8,32/3,32/3,32/3,8,16,8,8,16,16,16/3,8
};
// Flag to indicate if a song is currently playing
bool songPlaying = false;
// Variable to store the previous state of the button
bool lastButtonState = false;
// Setup function to initialize the pins
void setup() {
  // Set the buzzer pin as output
  pinMode(BUZZER_PIN, OUTPUT);
  // Set the button pin as input with internal pull-up resistor enabled
  pinMode(BUTTON_PIN, INPUT_PULLUP);
}
// Loop function to continuously check for button presses and play melodies
void loop() {
  // Read the current state of the button
  bool buttonState = digitalRead(BUTTON_PIN);
  // Check if the button is pressed and it was not pressed in the previous loop iteration
  if (buttonState == LOW && lastButtonState == HIGH) {
    // Toggle the song playing state
    songPlaying = !songPlaying;
    // Start or stop playing the selected song
    if (songPlaying) {
      // If the potentiometer value is less than 512, play the first melody; otherwise, play the second melody
      if (analogRead(POTENTIOMETER_PIN) < 512) {
        playMelody(melody1, noteDurations1, sizeof(melody1) / sizeof(int));
      } else {
        playMelody(melody2, noteDurations2, sizeof(melody2) / sizeof(int));
      }
    } else {
      // If the song was playing, stop playing it
      noTone(BUZZER_PIN);
    }
  }
  // Update the last button state for the next iteration
  lastButtonState = buttonState;
}
// Function to play a melody
void playMelody(int melody[], int noteDurations[], int size) {
  // Iterate over each note in the melody
  for (int thisNote = 0; thisNote < size; thisNote++) {
    // Calculate the duration of the current note
    int noteDuration = 1000 / noteDurations[thisNote];
    // Play the current note on the buzzer pin
    tone(BUZZER_PIN, melody[thisNote], noteDuration);
    // Wait for the duration of the note
    delay(noteDuration * 2);
    // Stop playing the note
    noTone(BUZZER_PIN);
    // Add a short pause between notes
    delay(noteDuration * 0.1);
  }
}

Challenges and reflections:

Initially, we had a few issues with coding for the potentiometer to change from one song to another using the potentiometer. We also had a few issues with triggering the song to play when the button is pressed. We managed to do it after trial and error.

For future improvements, we would like to configure an intricate system of LEDs into the board and program them to blink following the notes of the song being played, simulating a “mini club” when the room lights are turned off. We also want to have one song easing into the other while turning the potentiometer’s knob instead of them playing separately.