14 March 2021

Project: NIME

 


Heya all, so this is my little soundbox meant to prove a constant source of acoustic noise while the user can freely adjust and dial in a digital tone. Within the box, there is a servo motor that spins a plastic mount to create a constant percussion noise, while the other side is where things get a lot more interesting. The end result is a low to high tonal sound, but to create it all you simply have to do is create capacitance by touching the small metal wire. To adjust the sound there are multiple ways to do so, within the box you can utilize the pressure buttons to increase or decrease an "offset" variable, while on the outside of the box you can twist the knob of a potentiometer to dim or brighten a white led. This led is mapped to the photosensor on the CPE to create a natively higher sound the brighter the light is or lower if less light is available! I suppose one question I have for anyone curious to give an answer is thus: With the small and rackety motor we have available to us, what is the most pleasing sound you think you can create? Personally, I think it may be glass but didn't have any at my disposal to try, I saw someone else do wood which was interesting, but by and large, the motor's own noise is obnoxious.


And finally the Schematic:


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

int speaker = 0;
int leftButton = 4;
int rightButton = 5;
int slideSwitch = 7;
int freq = 500;
int offset = 0;
Servo myServo;
int pos = 0;
int inc = 1;
int timer = 0; 

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600); // init Serial Monitor
  delay(100); // pause
  CircuitPlayground.begin(); // init CPE
  pinMode(leftButton, INPUT_PULLDOWN); // init left push button
  pinMode(rightButton, INPUT_PULLDOWN); // init right push button
  pinMode(A8, INPUT); //init light sensor
  pinMode(A4, INPUT); //init capitence sensor
  pinMode(speaker, OUTPUT); // init speaker
  myServo.attach(10);
}

void loop() {
 /*Welcome to my little instrument, the way it works is the by touching your finger to the white wire
  * it will play a tone, to change the tone, you can turn the potentiometer to dim or brighten the white
  * LED inside, brighter light equals higher tones, less light lower tones. If you want to manually 
  * adjust the tone to dial into a sound, use the buttons, the left button will decrease the frequency 
  * by 10 on each press, the right button will increase frequency by 10. Create something interesting
  * alongside the thrumming of the servo!
  */
if(digitalRead(leftButton)) {   // if reading the left button returns true
    offset -= 10;   // decrease tone frequency by 10
    delay(500); //wait half sec, this prevent rapid acceleration
  } else if(digitalRead(rightButton)) { // if reading the right button returns true
    offset += 10;   //  increase tone frequency by 10
    delay(500);   //wait half sec, this prevent rapid acceleration
  }
  if (CircuitPlayground.readCap(A4) > 1000){  //If the capacitance is greater than 1000, (This should prevent minor movements from activatinng and should activate only on good contact with finger)
    int light = analogRead(A8); //read the data from photosensor
    freq = map(light, 0, 150, 100, 500); // pair the light values from 0 to 150 to 100hz to 500hz
    CircuitPlayground.playTone(freq+offset, 100); //Play a quick tone equal to freq reading plus offset
  }
  if (millis() > timer + 15) {
    myServo.write(0);
    timer = millis();
  } else if (millis() < timer +15){
    myServo.write(180);
  }

  Serial.print(analogRead(A8));
  Serial.print("\t");
  Serial.println();
}





No comments:

Post a Comment

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