14 March 2021

Scaffolding: NIME Midi Box

 

Top of the box, showing the CPE and capacitive touch sensors.


Inside of the box, showing servo and breadboard w/ potentiometer.

     For the NIME scaffolding, my first idea was a kind of midi using the speaker of the Circuit Playground Express. My conceptual model used the servo as a kind of metronome with an adjustable speed using the potentiometer. After messing around with the code, I realized that the code for that to happen was interrupting the capacitive touch sensor code so I switched up the purpose of those components. Now, the servo is manually controlled with the potentiometer to create a sound on the inside of the box. The capacitive touch sensors were always a part of the original concept; they would work the best for the midi aesthetic. 

    The mapping of the inputs to the outputs was simple; three different tones were mapped to the touch sensors and the output was the A0 pin, or the built-in speaker of the CPE. For the potentiometer and the servo, the values of the potentiometer were mapped 1:1 to the 180 degrees of the servo fan. 
When it came to the UX, I made sure that the touch sensors were clear and what they did was clear as well; the styrofoam keys I made signify that pressing the pennies (touch sensors) will illicit sound from the speaker of the CPE. On top of that, the sound and the different colored lights that flash when each sensor is touched act as feedback to the user.  

    How else could I have used the servo and the potentiometer, whether they worked together or separately?

Circuit schematic.

//CODE BY SAMANTHA BARRIZONTE 2021
//DIG3620

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

Servo myservo;  // create servo object to control a servo


int pos = 0;    // variable to store the servo position
int potpin = 3;  // analog pin used to connect the potentiometer
int timer = 0;
int val; // variable to store the potentiometer values

int thresh = 950;
int debounce = 15;
int r = A6;
int x = A7;
int s = A4;
 
#define COLOR1         0XFF0000
#define COLOR2         0X00FF00   
#define COLOR3         0X0000FF     

void setup() {
  Serial.begin(9600);
  delay(1000);
  CircuitPlayground.begin();
  myservo.attach(A2); // attaches the servo on A2 to the servo object 
  CircuitPlayground.setBrightness(70); //brightness of blinking neopixels
}

void loop() {
    val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023)
    val = map(val, 0, 1023, 0, 180);     // scale it to use it with the servo (value between 0 and 180)
    myservo.write(val);                  // sets the servo position according to the scaled value
    delay(10);                           // waits for the servo to get there
      
    int t = CircuitPlayground.readCap(r);  //read pin A6
    if(t > thresh) {
      CircuitPlayground.playTone(1760,100);
      for (int pixel=0; pixel<10; pixel++) { //all neopixels blink along to touch sensor
      CircuitPlayground.setPixelColor(pixel, COLOR1);    
      }   
      delay(debounce*2);
      CircuitPlayground.clearPixels();
      delay(debounce*2); 
    } 
    int y = CircuitPlayground.readCap(x); //read pin A7
    if(y > thresh) {
      CircuitPlayground.playTone(440,100);
       for (int pixel=0; pixel<10; pixel++) { //all neopixels blink along to touch sensor
      CircuitPlayground.setPixelColor(pixel, COLOR2);    
      }   
      delay(debounce*2);
      CircuitPlayground.clearPixels();
      delay(debounce*2); 
    } 
    int i = CircuitPlayground.readCap(s); //read pin A4
    if(i > thresh) {
      CircuitPlayground.playTone(880,100);
      for (int pixel=0; pixel<10; pixel++) { //all neopixels blink along to touch sensor
      CircuitPlayground.setPixelColor(pixel, COLOR3);    
      }   
      delay(debounce*2);
      CircuitPlayground.clearPixels();
      delay(debounce*2); 
    } 
      Serial.println();
      delay(debounce);   
 }

CONTENT WARNING: FLASHING LIGHTS







No comments:

Post a Comment

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