20 March 2022

NIME Team 4

 David Trefry and Adnane Rihani

 


NIME Team 4:

This instrument creates notes and a rhythm when it is played. The user can adjust the speed of the rhythm, play musical notes, and change the note played. The user plays by using both hands. One hand operates a knob while the other presses two buttons.

Our instrument is built from an Adafruit Circuit Playground, a breadboard, and its components: a servo, a potentiometer, and two tactile buttons. These elements are enclosed in a phone box with openings for accessing the USB powering the Playground, the tactile buttons, and the potentiometer’s knob.

This device uses three inputs and two outputs. The first button is mapped to play a tone from the Playground while it is pressed. The second button’s input is mapped to change the speed of the servo which creates a rhythm as it turns repeatedly. The potentiometer input is mapped to two different outputs; a scale of notes that adjusts the note played by the Playground and a range of speeds that the servo can move when the second button is pressed.

Our instrument’s signifiers are the input devices themselves: the tactile buttons and potentiometer knob. The enclosure for our instrument is a simple while box, so the only areas which suggest interactivity are where the knob and buttons on the breadboard are exposed. We cut holes into the box as well, which naturally contrast the smooth surface of the rest of the box.

Our device’s conceptual model is inherits from a guitar. Like a guitar, one hand is used to adjust the sounds users make while the other makes said sounds. Like a guitar, the user is meant to hold the enclosure in one hand which also twists the knob, while their other hand is positioned to press the buttons.

For peer review: Without an explanation of how this device works, how difficult do you feel it would be to figure out how to operate it? How might its mapping be adjusted or the enclosure appearance itself help it be easier to understand how to use it?

 

Schematic:

 

Video:

 

Code:

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

//Written by David Trefry and Adnane Rihani

// A, B, C, D, E, F, G, A
//440, 493.88, 523.25, 587.33, 659.25, 698.46, 783.99, 880
//notes array
float notes[] = {440, 493.88, 523.25, 587.33, 659.25, 698.46, 783.99, 880};

//servo declaration and movement without delays
Servo myServo;
int pos = 0;
int inc = 1;
int timer = 0;
int speedResult = 10;

//note timer
int noteTimer = 0;

//pins
int potPin = 3; //A4
int noteButtonPin = 6; //A1
int speedButtonPin = 9; //A2

//range of pot values
int minNoteVal = 50;
int maxNoteVal = 800;

void setup() {
  //standard setup
  Serial.begin(9600);
  delay(100);
  CircuitPlayground.begin();
 
  //pin setup
  myServo.attach(10); //A3
  pinMode(noteButtonPin, INPUT_PULLDOWN);
  pinMode(speedButtonPin, INPUT_PULLDOWN);
}

void loop() {
  //reading potentiometer value and storing it
  int potValue = analogRead(potPin);

  //setting range of pot values dynamically based on the analog inputs from the potentiometer
  if(potValue < minNoteVal){
    minNoteVal = potValue;
  }
  if(potValue > maxNoteVal){
    maxNoteVal = potValue;
  }

  //mapping potentiometer to value used for controlling the notes played
  int potNoteMap = map(potValue, minNoteVal, maxNoteVal, 0, 8);

  //mapping potentiometer to value used for controlling the speed of the servo
  int potSpeedValue = analogRead(potPin);
  int potSpeedMap = map(potSpeedValue, minNoteVal, maxNoteVal, 1, 20);
  Serial.println(potSpeedMap);

  //updating speed of servo on button press
  if(digitalRead(speedButtonPin)){
    speedResult = potSpeedMap;
  }

  //Moving servo without delays
  if(millis() > timer + speedResult) {
    if(pos == 0) inc = 1;
    if(pos == 180) inc = -1;
    myServo.write(pos);
    pos += inc;
    timer = millis();
  }

  //playing notes upon button press
  int noteButtonState = digitalRead(noteButtonPin);
  if(noteButtonState == 0){
    CircuitPlayground.playTone(notes[potNoteMap], 0, false);
    //if(millis() > noteTimer + 500) {
      CircuitPlayground.playTone(0, 0, false);
      //noteTimer = millis();
    //}
  }
}

No comments:

Post a Comment

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