14 March 2021

NIME: Interrupting Music Box

 


This music box interrupts itself a lot.


Essentially, my idea for the project came as a series of interruptions, which in turn led me to want to create an interruptive music box. That is an intentional quality of this device. Essentially, it is mapped to accept input from both the right and left button on the circuit playground express, as well as accept input from the potentiometer. When a button is pressed, it overrides any other input. 


This project works through the use of two buttons, and by turning the potentiometer. Every single interaction with this project interrupts another aspect. When music is played, the servo will stop moving. Alternatively, pressing down on the right button will allow for a moment of escape from the music box’s clicking. The servo will remain paused for as long as the user holds down the right button. In regard to the potentiometer, when turned, the servo will interrupt its own spin cycle and go in an alternate direction. There is some indication drawn onto the box to let the user know what might happen based on interaction; however, the feedback is only apparent through an aggressive change in what is happening. 


This device is not so much a music box, as an annoying single person game. In some ways, I can see a similarity to an omnophone. 


I suppose the biggest question I have is how could I have improved the aesthetics to better depict my intention?



/*
 * NIME, Music Box
 * Melissa Wells
 */

#include <Adafruit_CircuitPlayground.h>
#include <Adafruit_Circuit_Playground.h>
#include <Servo.h>

//variables 
//Servo
Servo myServo;
int pos = 0; // actual Servo position
int inc = 1; // represents the condition the servo is in with 0 or 1

//potentiometer
const int potent = A1; //where potent connected
const int valueThreshold = 500;

int sensorValue = 0; //value read from potent
int mappedPotent = 0;


//is song playing
bool song = false; 

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  CircuitPlayground.begin();
  
  //Servo Stuff
  delay (1000);
  myServo.attach(10); //10 = A3
  pinMode(13, OUTPUT);
  pinMode(4, INPUT_PULLDOWN);
  


}

void loop() {
    
  // put your main code here, to run repeatedly:

  //if you press the left button, start the song
  if(CircuitPlayground.leftButton()) {   // if reading the left button returns true
    song = true;
    PlaySong();
  }
  
  //if you hold down the right button, interrupt Servo's percussion
  else if(CircuitPlayground.rightButton()) { // if reading the right button returns true
    if (pos == 0) inc = 1;
    if (pos == 180) inc = -1;
    myServo.write (pos);
    pos += inc;
    delay(sensorValue);
    //delay(15);
    digitalWrite(13, digitalRead(4)); 
  } 

//control which direction the Servo moves in based on potentiometer
  sensorValue = analogRead(potent);
  if (sensorValue > valueThreshold)
  {
    myServo.write(90); }
    else
    {myServo.write(0);}

}  

void PlaySong()
{
  if (song == true)
  {
    CircuitPlayground.playTone(800,400);
    CircuitPlayground.playTone(700,200);
    CircuitPlayground.playTone(600,200);
    CircuitPlayground.playTone(800,100);
    CircuitPlayground.playTone(600,200);
    CircuitPlayground.playTone(800,400);
    CircuitPlayground.playTone(700,100);
    delay(200);
    CircuitPlayground.playTone(800,400);
    CircuitPlayground.playTone(700,200);
    CircuitPlayground.playTone(600,200);
    CircuitPlayground.playTone(800,100);
    CircuitPlayground.playTone(600,200);
    CircuitPlayground.playTone(800,400);
    CircuitPlayground.playTone(700,100);
  }

  song = false;
}







No comments:

Post a Comment

Note: Only a member of this blog may post a comment.