21 March 2022

NIME Project - Team 18

 The Blue Moon

Description

The conceptual model for our NIME project is similar to that of a game controller, being a rectangular box with a wire at the end and inputs located on top. The mapping is relatively simple. The left button of the circuit bluefruit express is the button to play a tone, the X and Y accelerometer determines the pitch of said tone in a 360 degree circle around the CPE. The potentiometer maps to the rate at which the servo moves back in forth, creating a rhythm. This mapping is set from 0 - 1023 and 5-15 as a rate of degrees that the servo turns. As far as signifiers and feedback go, the potentiometer has a knob on the end and a label reading "Rhythm" to signal its purpose. The button has a small arrow pointing to it, and the pitch of the audio is noted by the currently lit neopixel on the circuit bluefruit. For example, the top left most neopixel is an A proceeding up in pitch by a half step as you go counter clockwise around.

For my question I would ask, would handles on the sides have been a good idea? Explain?

Circuit Schematic

Code

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


//set up the notes per neonum & servo
float note[] = {220.00, 233.08, 246.94, 261.63, 277.18, 293.66, 311.13, 329.63, 349.23, 369.99};
Servo myServo;
int sensorValue = 0;
int outputValue = 0;
int pos = 0;
int inc = 1;

void setup() {
  // put your setup code here, to run once:
  delay(1000);
  pinMode(CPLAY_LEFTBUTTON, INPUT_PULLDOWN); //BUTTON A
  Serial.begin(9600);
  CircuitPlayground.begin();
  myServo.attach(A6);
  pinMode(13, OUTPUT);
  
}

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

    //potentiometer tests
    sensorValue = analogRead(A4);
    Serial.print("sensor value =");
    Serial.print(sensorValue);
    outputValue = map(sensorValue, 0, 1023, 1, 15);
    Serial.print("\t output =");
    Serial.println(outputValue);
    
    // Update servo position for rhythm, adjust loop via output values
  if (pos <= 0)
  {
    inc = 1;
  }
  if (pos >= 180)
  {
    inc = -1;
  }
  myServo.write(pos);
  pos += inc * outputValue;
  delay(15);

  
       //read accelerometer x & y
  float x = CircuitPlayground.motionX();
  float y = CircuitPlayground.motionY();
  float rad = atan2(y, x);

  //check the angle & light the appropriate neopixel
  int neonum = mapfloat(rad, -PI, PI, 0, 10);
  neonum = neonum - 2;
  
  if (neonum < 0)
    neonum += 10;

    //Serial.println(neonum);
 
 CircuitPlayground.clearPixels();
 CircuitPlayground.setPixelColor(neonum, 00,00,250;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      ');

 if (digitalRead(CPLAY_LEFTBUTTON))
  {
    CircuitPlayground.playTone(note[neonum], 100, false);
  }
   
}
// trig math for determining tilt spot
float mapfloat(float x, float in_min, float in_max, float out_min, float out_max) {
  float result = (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
  return result;
}

Video




No comments:

Post a Comment

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