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.

 

Leave a Reply