13 March 2021

Scaffolding NIME Music Box

I do want to formally apologize for not making a music box for I was dealing with personal matters and so forth. I wanted to turn something in and get some results back rather than turn in nothing at all. For the music box I had in mind, I wanted the design to be enclosed in a good sized square box that I could have room to put the breadboard, circuit playground express, and other components inside it. There are three key components that make it all come together. First, the CPE is connected to a 1K resistor with potentiometer that controls the brightness of the blue LED. Second, it is then passing a current to whenever the button is pushed, it turns the servo motor back and forth 90 degrees and makes a distinctively precarious noise. The servo motor would be at the far end of the box in order to create more space for the more complex components. Last, the switch would activate the speaker that will play "Happy birthday" tune whenever it's on. Then, whenever it's off, the music would stop. My question to you is how could I have designed the box in way that would be able to fit, be professional, and meet criteria for this project? I do again want to apologize for not turning in a full project due to personal issues, but would rather turn in something and get some grade rather than nothing at all. 



 






                                                                                                                                                        

/* Music Box

    By John Keith

*/


//Libraries

#include <Servo.h>

#include <Adafruit_Circuit_Playground.h>

#include <Adafruit_CircuitPlayground.h>

#define LED 10


Servo myServo; //Create servo object to control servo


//Variables

int neoState = 0;

int bCurrent = 0;

int bPrevious = 0;

int pot = 0;


void setup()

{

  CircuitPlayground.begin(); //Starts up playground

  myServo.attach(A6); // Attaches the servo from A6 on CPE to pin 9 on breadboard

  pinMode (LED, OUTPUT); //Output

  Serial.begin(9600);

  delay(1000);

}


void loop()

{

  if (digitalRead(CPLAY_RIGHTBUTTON)) //makes servo turn 90 degrees back and fourth

  {

    delay(200);

    myServo.write(90);

    delay(200);

    delay(200);

    myServo.write(0);

    delay(200);

  }


  if (digitalRead(CPLAY_SLIDESWITCHPIN)) //If switch turns on, melody plays

    "Happy birthday";

  {

    CircuitPlayground.playTone(700, 200);

    CircuitPlayground.playTone(600, 200);

    CircuitPlayground.playTone(500, 200);

    CircuitPlayground.playTone(600, 200);

    CircuitPlayground.playTone(700, 200);

    CircuitPlayground.playTone(700, 200);

    CircuitPlayground.playTone(700, 200);

    delay(300);

    CircuitPlayground.playTone(600, 200);

    CircuitPlayground.playTone(600, 200);

    CircuitPlayground.playTone(600, 200);

    delay(300);

    CircuitPlayground.playTone(700, 200);

    CircuitPlayground.playTone(1000, 200);

    CircuitPlayground.playTone(1000, 200);

  }


  //Potentiometer control

  pot = analogRead (A4);

  Serial.println (pot);

  pot = map(pot, 1, 1024, 1, 255);

  analogWrite(LED, pot);

}




No comments:

Post a Comment

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