20 March 2022

Project: NIME, Team 11

 NIME TEAM 11


For this project, I wanted to create something akin to a piano keyboard. The goal was to play a range of notes with the button and use the instruments attached to the fan on the servo to produce background noise in addition to the notes being played.




So for the notes I chose the main ones from the song Runaway by Kanye West. It features a multitude of E sharps, C sharps, etc. I put those frequencies into an array in the IDE and allowed it to be played in full at the press of a button. I wanted to be able to cycle through them somehow but couldn't exactly figure out the code for that in time so I just settled for the whole range at one click of a button. The servo moves when turning the knob on the potentiometer. As it moves, the bells stringed to it jingle off the board and each other to produce a jingling sound in the background of the notes.



//NIME Project by Justice Anderson & Jared Toavs
//DIG3602C Professor Mosher
#include <Servo.h>
#include <Adafruit_CircuitPlayground.h>
#include <Adafruit_Circuit_Playground.h>

//servo 
Servo myServo;
int timer = 0;
int inc = 1;

//potentiometer variables
int potpin = A1;  // analog pin used to connect the potentiometer
int val;    // variable to read the value from the analog pin

//array of notes in the song Runaway by Kanye West
float notes[] = {261.63, 261.63, 261.63, 261.63, 261.63, 261.63, 261.63, 261.63, 
261.63, 261.63, 261.63, 261.63, 261.63, 261.63, 261.63, 311.127, 311.127, 311.127,
277.18, 277.18, 466.164, 466.164, 261.63};

void setup() {
  // put your setup code here, to run once:
  CircuitPlayground.begin();
  Serial.begin(9600);
  delay(1000);

  //servo code
  myServo.attach(10); //A3
  pinMode(4, INPUT_PULLDOWN); //left button
  pinMode(5, INPUT_PULLDOWN); //right button
}

void loop() {
  val = analogRead(potpin); // gets the value of the potentiometer 
  val = map(val, 0, 1023, 0, 180); // converts it ton a number usable by the servo
  if(millis() > timer + 15) {
    if(val == 0) inc = 1;
    if(val == 180) inc = -1;
    myServo.write(val); // the servo is set to the stored value from the potentiometer
    val += inc;
    timer = millis();
  }

  
  if(digitalRead(5)) { // checks if button is clicked
  for(int i = 0; i < 23; i++) { // when button is clicked it loops through until it hits 23    CircuitPlayground.playTone(notes[i], 500); // plays the notes in the notes array
    }
  }
}

Do you think the enclosure being better crafted would enhance the experience and would there be a better way of stringing the bells onto the servo fan?


No comments:

Post a Comment

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