20 March 2022

NIME Team 1


 NIME TEAM 1


For the NIME assignment, we wanted to create an instrument that would draw inspiration from the Otamatone, allowing the user to adjust the pitch of the notes and the speed of the server using two separate potentiometers.



Once the right button is pressed, the instrument will begin to play the notes A, G, D, and E repeatedly, and the player will be able to use the first potentiometer to adjust the pitch of the notes to be lower or higher. 

Pressing the left button will turn on the servo, which we used to create an acoustic sound inside of the instrument.

The interior of the NIME

There is a dowel attached to the servo, so the servo will make the dowel tap against the cookie sheet much like a drumstick. We used a cookie sheet in order to produce a metallic sound to match the digital tones produced by the CPB. 

The speed of the dowel is also adjustable based on the second potentiometer. This is possible because of the mapping we used when setting up the potentiometer, using a 1:1 pairing where the potentiometer can affect the digital and analog outputs.

NIME Schematic

The wiring, CPB, and two knobs serve to signify the use of the music box. Feedback is especially noticeable when it comes to the use of the servo, as the dowel will immediately hit the cookie sheet to create the acoustics.

The supports of the NIME interior, allowing for the removal of the
cookie sheet and allowing space for the sheet to reverberate.


//NIME Team 1: Jacqueline Pavlat & Jeffrey Jourdan

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

//Servo-related variables
Servo serv;
int servOn = 0;
int servSpeed = 5;
int pos = 0;
int inc = 1;
int timer = 0;
int sCurrent = 0;
int sPrev = 0;

//Tone-related variables
int playNote = 0;
int pitch = 1;
int bCurrent = 0;
int bPrevious = 0;
float notes[] = {440, 587.33, 659.25, 782.99};


void setup() 
{
  Serial.begin(9600);
  delay(1000);
  CircuitPlayground.begin();

  //PinOuts
  serv.attach(6); //Servo: A1
  pinMode(4, INPUT_PULLDOWN); //Left/A Button
  pinMode(5, INPUT_PULLDOWN); //Right/B Button
  
}

void loop() 
{
  //TONE-RELATED CODE

  
  //Turns on tones on pressing Right/B
  bCurrent = digitalRead(CPLAY_RIGHTBUTTON);
  if(bCurrent == 1 && bPrevious == 0)
   {
      playNote = 1;
   }
   
  //Plays tones
  if(playNote == 1)
  {
    for(int i =0; i < 4; i++)
    {
    CircuitPlayground.playTone(notes[i] + pitch, 250);
    }
  }
  bPrevious = bCurrent; //Updates Check
  //Stops tones
  if(digitalRead(CPLAY_RIGHTBUTTON) && playNote == 1)
  {
    playNote = 0;
  }
  
  //SERVO-RELATED CODE

  
  //Turns on servo on pressing Left/A
  sCurrent = digitalRead(CPLAY_LEFTBUTTON);
  if(sCurrent == 1 && sPrev == 0)
  {
    servOn = 1;
  }
  
  // Makes servo hit cookie sheet and top of box
  if(servOn == 1)
  {
    if(millis() > timer + servSpeed)
    {
      if(pos == 35) inc = 1;
      if(pos == 90) inc = -1;
      serv.write(pos);
      pos += inc;
      timer = millis();
    }
    
  }

  //POTENTIOMETER-RELATED CODE


  //Pitch Potentiometer (Blue/Right)
  pitch = analogRead(A2);
  pitch = map(pitch,1,1023, 1, 260); //Maps pitch to blue potentiometer with high of 1023 & low of 260
  //Tempo Potentiometer (Red/Left)
  servSpeed = analogRead(A3);
  servSpeed = map(servSpeed, 5, 1023, 5, 25); //Maps speed to potentiometer with high of 1023 & low of 25
}


How could we improve the UI or visual signifiers for the music box without the use of labels?





No comments:

Post a Comment

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